Exception: Trycourier::Errors::ConversionError

Inherits:
Error
  • Object
show all
Defined in:
lib/trycourier/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(on:, method:, target:, value:, cause: nil) ⇒ ConversionError

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ConversionError.



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/trycourier/errors.rb', line 22

def initialize(on:, method:, target:, value:, cause: nil)
  cls = on.name.split("::").last

  message = [
    "Failed to parse #{cls}.#{method} from #{value.class} to #{target.inspect}.",
    "To get the unparsed API response, use #{cls}[#{method.inspect}].",
    cause && "Cause: #{cause.message}"
  ].filter(&:itself).join(" ")

  @cause = cause
  super(message)
end

Instance Method Details

#causeStandardError?



13
# File 'lib/trycourier/errors.rb', line 13

def cause = @cause.nil? ? super : @cause