Exception: Jsapi::DSL::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Jsapi::DSL::Error
- Defined in:
- lib/jsapi/dsl/error.rb
Overview
Raised when an error occurred while defining an API component.
Instance Method Summary collapse
-
#initialize(error_or_message, origin = nil) ⇒ Error
constructor
Creates a new error.
-
#message ⇒ Object
Overrides
StandardError#message
to append the whole path of the position at where the error occurred, for example:{message} (at foo / bar)
. -
#prepend_origin(origin) ⇒ Object
Prepends
origin
to the path at where the error occurred.
Constructor Details
#initialize(error_or_message, origin = nil) ⇒ Error
Creates a new error. origin
is the innermost position at where the error occurred.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/jsapi/dsl/error.rb', line 10 def initialize(, origin = nil) @path = Array(origin) super( if .respond_to?(:message) . else end ) end |
Instance Method Details
#message ⇒ Object
Overrides StandardError#message
to append the whole path of the position at where the error occurred, for example: {message} (at foo / bar)
.
24 25 26 27 28 29 |
# File 'lib/jsapi/dsl/error.rb', line 24 def = super return if @path.empty? "#{} (at #{@path.join(' / ')})" end |
#prepend_origin(origin) ⇒ Object
Prepends origin
to the path at where the error occurred.
32 33 34 35 |
# File 'lib/jsapi/dsl/error.rb', line 32 def prepend_origin(origin) @path.prepend(origin) if origin.present? self end |