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.
Class Method Summary collapse
- .cause_text(cause) ⇒ Object private private
- .exception_text(exception) ⇒ Object private private
-
.handle_exception(output, exception, _pry_instance) ⇒ Object
private
Will only show the first line of the backtrace.
- .standard_error_text_for(exception) ⇒ Object private private
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.
42 43 44 45 |
# File 'lib/pry/exception_handler.rb', line 42 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.
32 33 34 35 36 37 38 39 40 |
# File 'lib/pry/exception_handler.rb', line 32 def exception_text(exception) if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.2') "#{exception.class}: #{exception.message}\n" \ "from #{exception.backtrace.first}\n" else "#{exception.class}: #{exception.detailed_message}\n" \ "from #{exception.backtrace.first}\n" end 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.
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.
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 |