Exception: Siwe::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/siwe/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, expected: nil, received: nil, message: nil) ⇒ Error

Returns a new instance of Error.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
# File 'lib/siwe/error.rb', line 9

def initialize(type, expected: nil, received: nil, message: nil)
  raise ArgumentError, "unknown SIWE error type: #{type.inspect}" unless ErrorType::MESSAGES.key?(type)

  @type = type
  @expected = expected
  @received = received
  super(message || ErrorType::MESSAGES.fetch(type))
end

Instance Attribute Details

#expectedObject (readonly)

Returns the value of attribute expected.



7
8
9
# File 'lib/siwe/error.rb', line 7

def expected
  @expected
end

#receivedObject (readonly)

Returns the value of attribute received.



7
8
9
# File 'lib/siwe/error.rb', line 7

def received
  @received
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/siwe/error.rb', line 7

def type
  @type
end

Instance Method Details

#to_hObject



18
19
20
# File 'lib/siwe/error.rb', line 18

def to_h
  { type: @type, expected: @expected, received: @received, message: message }
end