Exception: NRSER::MultipleErrors
- Inherits:
-
StandardError
- Object
- StandardError
- NRSER::MultipleErrors
- Defined in:
- lib/nrser/errors.rb
Overview
A wrapper error around a list of other errors.
Instance Attribute Summary collapse
-
#errors ⇒ Array<Exception>
readonly
The individual errors that occurred.
Instance Method Summary collapse
-
#initialize(errors, headline: nil) ⇒ MultipleErrors
constructor
Instantiate a new ‘MultipleErrors`.
Constructor Details
#initialize(errors, headline: nil) ⇒ MultipleErrors
Instantiate a new ‘MultipleErrors`.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/nrser/errors.rb', line 78 def initialize errors, headline: nil @errors = errors if headline.nil? class_counts = NRSER.count_by( errors, &:class ). map { |klass, count| "#{ klass } (#{ count })" }. join( ', ' ) headline = "#{ errors.count } error(s) occurred - #{ class_counts }" end = NRSER.erb binding, <<-END <%= headline %> <% errors.each_with_index do |error, index| %> <%= (index.succ.to_s + ".").ljust( 3 ) %> <%= error.message %> (<%= error.class %>): <%= error.backtrace.join( $/ ) %> <% end %> END super end |
Instance Attribute Details
#errors ⇒ Array<Exception> (readonly)
The individual errors that occurred.
71 72 73 |
# File 'lib/nrser/errors.rb', line 71 def errors @errors end |