Exception: ReeMapper::ErrorWithLocation
- Defined in:
- lib/ree_lib/packages/ree_mapper/package/ree_mapper/errors/error_with_location.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#location ⇒ Object
Returns the value of attribute location.
Instance Method Summary collapse
- #field_name ⇒ Object
- #full_message ⇒ Object
-
#initialize(message, location = nil, field_name_parts = []) ⇒ ErrorWithLocation
constructor
A new instance of ErrorWithLocation.
- #message ⇒ Object
- #prepend_field_name(part) ⇒ Object
Constructor Details
#initialize(message, location = nil, field_name_parts = []) ⇒ ErrorWithLocation
Returns a new instance of ErrorWithLocation.
7 8 9 10 11 |
# File 'lib/ree_lib/packages/ree_mapper/package/ree_mapper/errors/error_with_location.rb', line 7 def initialize(, location = nil, field_name_parts = []) @message = @location = location @field_name_parts = field_name_parts end |
Instance Attribute Details
#location ⇒ Object
Returns the value of attribute location.
4 5 6 |
# File 'lib/ree_lib/packages/ree_mapper/package/ree_mapper/errors/error_with_location.rb', line 4 def location @location end |
Instance Method Details
#field_name ⇒ Object
20 21 22 |
# File 'lib/ree_lib/packages/ree_mapper/package/ree_mapper/errors/error_with_location.rb', line 20 def field_name @field_name_parts.reduce { "#{_1}[#{_2}]" } end |
#full_message ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/ree_lib/packages/ree_mapper/package/ree_mapper/errors/error_with_location.rb', line 47 def (...) msg = super return msg if location.nil? last_sym_idx = msg.index(/\).*\n/) return msg if last_sym_idx.nil? msg.insert(last_sym_idx + 1, ", located at #{location}") end |
#message ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ree_lib/packages/ree_mapper/package/ree_mapper/errors/error_with_location.rb', line 27 def msg = @message if location msg = "#{msg}, located at #{location}" end return msg if @field_name_parts.empty? "`#{field_name}` #{msg}" end |
#prepend_field_name(part) ⇒ Object
14 15 16 17 |
# File 'lib/ree_lib/packages/ree_mapper/package/ree_mapper/errors/error_with_location.rb', line 14 def prepend_field_name(part) @field_name_parts.unshift part nil end |