Sha256: 721a7c6c195bf4f2bd523690c37c3f15ac08d5a2d498f6c3b4af63fa78df5d2b

Contents?: true

Size: 1.07 KB

Versions: 6790

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

class Pry
  # @api private
  # @since v0.13.0
  module ExceptionHandler
    class << self
      # Will only show the first line of the backtrace.
      def handle_exception(output, exception, _pry_instance)
        if exception.is_a?(UserError) && exception.is_a?(SyntaxError)
          output.puts "SyntaxError: #{exception.message.sub(/.*syntax error, */m, '')}"
        else
          output.puts standard_error_text_for(exception)
        end
      end

      private

      def standard_error_text_for(exception)
        text = exception_text(exception)
        return text unless exception.respond_to?(:cause)

        cause = exception.cause
        while cause
          text += cause_text(cause)
          cause = cause.cause
        end

        text
      end

      def exception_text(exception)
        "#{exception.class}: #{exception.message}\n" \
        "from #{exception.backtrace.first}\n"
      end

      def cause_text(cause)
        "Caused by #{cause.class}: #{cause}\n" \
        "from #{cause.backtrace.first}\n"
      end
    end
  end
end

Version data entries

6,790 entries across 6,786 versions & 31 rubygems

Version Path
cybrid_api_organization_ruby-0.123.124 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_id_ruby-0.123.124 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_bank_ruby-0.123.123 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_id_ruby-0.123.123 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_organization_ruby-0.123.123 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_bank_ruby-0.123.122 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_organization_ruby-0.123.122 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_id_ruby-0.123.122 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_bank_ruby-0.123.121 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_id_ruby-0.123.121 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_organization_ruby-0.123.121 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_bank_ruby-0.123.120 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_organization_ruby-0.123.120 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_id_ruby-0.123.120 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
avalara_sdk-24.12.0 vendor/bundle/ruby/2.7.0/gems/pry-0.13.1/lib/pry/exception_handler.rb
cybrid_api_bank_ruby-0.123.119 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_organization_ruby-0.123.119 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_id_ruby-0.123.119 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_bank_ruby-0.123.118 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb
cybrid_api_id_ruby-0.123.118 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/exception_handler.rb