Exception: Dry::Protocol::NotImplemented
- Inherits:
-
StandardError
- Object
- StandardError
- Dry::Protocol::NotImplemented
- Defined in:
- lib/dry/errors/not_implemented.rb
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#proto ⇒ Object
readonly
Returns the value of attribute proto.
Instance Method Summary collapse
- #cause ⇒ Object
-
#initialize(type, proto, **details) ⇒ NotImplemented
constructor
A new instance of NotImplemented.
Constructor Details
#initialize(type, proto, **details) ⇒ NotImplemented
Returns a new instance of NotImplemented.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dry/errors/not_implemented.rb', line 6 def initialize(type, proto, **details) @proto, @details = proto, details @details[:message] = case type when :protocol "Protocol “#{@proto}” is not implemented for “#{@details[:receiver].class}”." when :method "Protocol “#{@proto}” does not declare method “#{@details[:method]}”." when :nested "Protocol “#{@proto}” failed to invoke the implementation for\n" \ " ⮩ “#{@details[:receiver].class}##{@details[:method]}”.\n" \ " ⮩ Caused by “#{cause.class}” with a message\n" \ " ⮩ “#{cause.}”\n" \ " ⮩ Rescue this exception and inspect `NotImplemented#cause' for details." when :arity "Attempt to implement “#{@proto}#@details[:method]}”\n" \ " ⮩ with a wrong arity for “#{@details[:target]}”.\n" \ " ⮩ Expected parameters types:\n" \ " ⮩ “#{@details[:expected]}”\n" \ " ⮩ Provided parameters types:\n" \ " ⮩ “#{@details[:provided]}”\n" \ " ⮩ Please consider providing a proper implementation." else "Protocol “#{proto}” is invalid." end super(@details[:message]) if @details[:cause] set_backtrace( @details[:cause].backtrace.reject do |line| # FIXME drop_while ?? line =~ %r[dry-behaviour/lib/dry/behaviour] end ) end end |
Instance Attribute Details
#details ⇒ Object (readonly)
Returns the value of attribute details.
4 5 6 |
# File 'lib/dry/errors/not_implemented.rb', line 4 def details @details end |
#proto ⇒ Object (readonly)
Returns the value of attribute proto.
4 5 6 |
# File 'lib/dry/errors/not_implemented.rb', line 4 def proto @proto end |
Instance Method Details
#cause ⇒ Object
44 45 46 |
# File 'lib/dry/errors/not_implemented.rb', line 44 def cause @details[:cause] ||= super end |