Exception: RescueEach::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rescue_each.rb

Defined Under Namespace

Classes: Item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(errors, aborted = false) ⇒ Error

Returns a new instance of Error.



10
11
12
13
# File 'lib/rescue_each.rb', line 10

def initialize(errors, aborted=false)
  @errors = errors
  @aborted = aborted
end

Instance Attribute Details

#abortedObject (readonly)

Returns the value of attribute aborted.



8
9
10
# File 'lib/rescue_each.rb', line 8

def aborted
  @aborted
end

#errorsObject (readonly)

Returns the value of attribute errors.



8
9
10
# File 'lib/rescue_each.rb', line 8

def errors
  @errors
end

Instance Method Details

#to_sObject



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rescue_each.rb', line 60

def to_s
  msg = []
  errors.each_with_index do |error, idx|
    msg << "rescue_each catch ##{idx+1}: "
    msg << error.to_s
    msg << "\n"
  end
  msg << "rescue_each caught #{errors.size} errors"
  msg << ", and then aborted." if aborted
  msg.join
end