Module: AMA::Entity::Mapper::Mixin::Errors
- Included in:
- Engine, Engine::RecursiveMapper, Handler::Entity::Denormalizer, Handler::Entity::Factory, Reflection, SuppressionSupport, Type, Type::Any, Type::Attribute, Type::BuiltIn::EnumerableType, Type::BuiltIn::HashType, Type::BuiltIn::HashType, Type::BuiltIn::PrimitiveType, Type::BuiltIn::PrimitiveType::Denormalizer, Type::Parameter, Type::Registry, Type::Resolver
- Defined in:
- lib/ama-entity-mapper/mixin/errors.rb
Overview
Simple mixin that provides shortcuts for raising common errors
Instance Method Summary collapse
- #compliance_error(message, **options) ⇒ Object
- #mapping_error(message, **options) ⇒ Object
-
#raise_if_internal(e) ⇒ Object
Raises error again if this is an internal error.
- #validation_error(message, **options) ⇒ Object
Instance Method Details
#compliance_error(message, **options) ⇒ Object
|
|
# File 'lib/ama-entity-mapper/mixin/errors.rb', line 20
|
#mapping_error(message, **options) ⇒ Object
|
|
# File 'lib/ama-entity-mapper/mixin/errors.rb', line 17
|
#raise_if_internal(e) ⇒ Object
Raises error again if this is an internal error
48 49 50 |
# File 'lib/ama-entity-mapper/mixin/errors.rb', line 48 def raise_if_internal(e) raise e if e.is_a?(Mapper::Error) end |
#validation_error(message, **options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ama-entity-mapper/mixin/errors.rb', line 25 error_types.each do |type| method = "#{type.to_s.downcase}_error" error_class = error_namespace.const_get("#{type}Error") define_method method do |, **| parent_error = [:parent] unless parent_error.nil? if [:signature] && parent_error.is_a?(ArgumentError) += '.' if /\w$/ =~ += ' Does called method have signature ' \ "#{[:signature]}?" end += '.' if /\w$/ =~ += " Parent error: #{parent_error.}" end if [:context] += " (path: #{[:context].path})" end raise error_class, end end |