Exception: StandardSingpass::Myinfo::Error

Inherits:
StandardError
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/standard_singpass/myinfo/error.rb

Overview

Base class for every error the gem raises.

Every error carries the two facts a host needs to decide what to tell the user, so neither has to be recovered by reading the message:

status — the HTTP status of the Singpass response that produced the error. Nil when there was no response (a transport failure) and for errors a host raises itself.

transport? — true when we never got an answer from Singpass at all (DNS, connection refused, TLS, read timeout — a Faraday::Error under the hood), as opposed to Singpass answering with something we can't use. Only the former is unambiguously their side being unreachable.

Both live on the base class rather than on ApiError alone because every leg of the flow raises its own class — PARError for PAR, ApiError for token and userinfo — and a host asking "is Singpass available?" needs the same answer from all of them. Scoping status to ApiError would silently misclassify a 502 from the PAR endpoint as "our request was wrong".

The alternative — matching "unreachable" or an HTTP code in message — is a trap: the message is not a stable interface. FailureClassifier consumes these so hosts never have to.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, status: nil, transport: false) ⇒ Error

Returns a new instance of Error.



44
45
46
47
48
# File 'lib/standard_singpass/myinfo/error.rb', line 44

def initialize(message = nil, status: nil, transport: false)
  super(message)
  @status = status
  @transport = transport
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



33
34
35
# File 'lib/standard_singpass/myinfo/error.rb', line 33

def status
  @status
end

Instance Method Details

#transport?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/standard_singpass/myinfo/error.rb', line 51

def transport?
  @transport
end