Class: Producer::Core::ErrorFormatter
- Inherits:
-
Object
- Object
- Producer::Core::ErrorFormatter
- Defined in:
- lib/producer/core/error_formatter.rb
Constant Summary collapse
- FILTERS =
[ /\/producer/, Regexp.new(RbConfig::CONFIG['rubylibdir']), /\/net-ssh/, /\/net-sftp/ ].freeze
Instance Method Summary collapse
- #debug? ⇒ Boolean
- #format(exception) ⇒ Object
-
#initialize(debug: false) ⇒ ErrorFormatter
constructor
A new instance of ErrorFormatter.
Constructor Details
#initialize(debug: false) ⇒ ErrorFormatter
Returns a new instance of ErrorFormatter.
11 12 13 |
# File 'lib/producer/core/error_formatter.rb', line 11 def initialize debug: false @debug = debug end |
Instance Method Details
#debug? ⇒ Boolean
15 16 17 |
# File 'lib/producer/core/error_formatter.rb', line 15 def debug? !!@debug end |
#format(exception) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/producer/core/error_formatter.rb', line 19 def format exception if debug? && exception.cause lines = format_exception exception, filter: true lines << '' lines << 'cause:' lines << format_exception(exception.cause, filter: false) else lines = format_exception exception, filter: !debug? end lines.join "\n" end |