Module: Pry::ExceptionHandler Private

Defined in:
lib/pry/exception_handler.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • ?.?.?

Class Method Summary collapse

Class Method Details

.cause_text(cause) ⇒ Object (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • ?.?.?


37
38
39
40
# File 'lib/pry/exception_handler.rb', line 37

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

.exception_text(exception) ⇒ Object (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • ?.?.?


32
33
34
35
# File 'lib/pry/exception_handler.rb', line 32

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

.handle_exception(output, exception, _pry_instance) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Will only show the first line of the backtrace.

Since:

  • ?.?.?


9
10
11
12
13
14
15
# File 'lib/pry/exception_handler.rb', line 9

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

.standard_error_text_for(exception) ⇒ Object (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • ?.?.?


19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pry/exception_handler.rb', line 19

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