Class: ConvenientService::Service::Plugins::RescuesResultUnhandledExceptions::Commands::FormatBacktrace
- Inherits:
-
ConvenientService::Support::Command
- Object
- ConvenientService::Support::Command
- ConvenientService::Service::Plugins::RescuesResultUnhandledExceptions::Commands::FormatBacktrace
- Defined in:
- lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_backtrace.rb
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#max_size ⇒ Object
readonly
Returns the value of attribute max_size.
Instance Method Summary collapse
- #call ⇒ String
- #initialize(backtrace:, max_size: Constants::DEFAULT_MAX_BACKTRACE_SIZE) ⇒ void constructor
Methods inherited from ConvenientService::Support::Command
Constructor Details
#initialize(backtrace:, max_size: Constants::DEFAULT_MAX_BACKTRACE_SIZE) ⇒ void
31 32 33 34 |
# File 'lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_backtrace.rb', line 31 def initialize(backtrace:, max_size: Constants::DEFAULT_MAX_BACKTRACE_SIZE) @backtrace = backtrace.to_a @max_size = max_size end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
13 14 15 |
# File 'lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_backtrace.rb', line 13 def backtrace @backtrace end |
#max_size ⇒ Object (readonly)
Returns the value of attribute max_size.
19 20 21 |
# File 'lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_backtrace.rb', line 19 def max_size @max_size end |
Instance Method Details
#call ⇒ String
Note:
Exceptions formatting is inspired by RSpec. It has almost the same output (at least for RSpec 3).
68 69 70 71 72 73 74 |
# File 'lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_backtrace.rb', line 68 def call = backtrace.take(max_size).map { |line| Commands::FormatLine.call(line: line) }.join("\n") << "\n# ..." if backtrace.size > max_size end |