Exception: 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`.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/nrser/errors.rb', line 42 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 = binding.erb <<-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 |