Class: Modulorails::ErrorData
- Inherits:
-
Object
- Object
- Modulorails::ErrorData
- Defined in:
- lib/modulorails/error_data.rb
Overview
An error encountered during an operation with additional data.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#r errors(errors) ⇒ Object
An error message or an array of error messages (those will be joined by a coma and a space).
-
#r exception(exception) ⇒ Object
The exception that caused the error.
Instance Method Summary collapse
-
#initialize(errors, exception: nil) ⇒ ErrorData
constructor
A new instance of ErrorData.
-
#success? ⇒ false
An error always means the operation was not a success.
Constructor Details
#initialize(errors, exception: nil) ⇒ ErrorData
Returns a new instance of ErrorData.
13 14 15 16 |
# File 'lib/modulorails/error_data.rb', line 13 def initialize(errors, exception: nil) @errors = errors.respond_to?(:join) ? errors.join(', ') : errors.to_s @exception = exception end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/modulorails/error_data.rb', line 9 def errors @errors end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
9 10 11 |
# File 'lib/modulorails/error_data.rb', line 9 def exception @exception end |
#r errors(errors) ⇒ Object
An error message or an array of error messages (those will be joined by a coma and a space).
9 |
# File 'lib/modulorails/error_data.rb', line 9 attr_reader :errors, :exception |
#r exception(exception) ⇒ Object
The exception that caused the error. Defaults to nil.
9 |
# File 'lib/modulorails/error_data.rb', line 9 attr_reader :errors, :exception |
Instance Method Details
#success? ⇒ false
Returns An error always means the operation was not a success.
19 20 21 |
# File 'lib/modulorails/error_data.rb', line 19 def success? false end |