Sha256: 41e12bfe78ab5a8e8e9868a36c587584ad4fabb443a17236325ab05242a17640
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true require_relative "base" require_relative "exceptions/active_record/statement_invalid" require_relative "exceptions/active_record/configuration_error" require_relative "exceptions/name_error/handler" require_relative "exceptions/no_method_error" require_relative "constants/errors" class ExceptionsHandler < Base attr_reader :exception, :output, :pry def initialize(output, exception, pry) @output = output @exception = exception @pry = pry end def call case exception in NoMethodError Exceptions::NoMethodError.call(output, exception, pry) in NameError # NameError is a Superclass for all undefined statement. Exceptions::NameError::Handler.call(output, exception, pry) in ActiveRecord::StatementInvalid # ActiveRecord::StatementInvalid is a Superclass for all database execution errors. # We only need to one including an `UndefinedTable` error. return pry_exception_handler unless exception.message.include?(Constants::Errors::UNDEFINED_TABLE) Exceptions::ActiveRecord::StatementInvalid.call(output, exception, pry) in ActiveRecord::ConfigurationError Exceptions::ActiveRecord::ConfigurationError.call(output, exception, pry) else pry_exception_handler end end private def pry_exception_handler Pry::ExceptionHandler.handle_exception(output, exception, pry) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pry-byetypo-1.3.2 | lib/pry-byetypo/exceptions_handler.rb |
pry-byetypo-1.3.1 | lib/pry-byetypo/exceptions_handler.rb |
pry-byetypo-1.3.0 | lib/pry-byetypo/exceptions_handler.rb |