Exception: Basecamp::Oauth::DeviceFlowError

Inherits:
OauthError
  • Object
show all
Defined in:
lib/basecamp/oauth/device_flow_error.rb

Overview

A terminal RFC 8628 device-flow outcome. Carries a reason; the parent OauthError type is DERIVED from that reason (SPEC.md ยง16) so callers can branch on either the precise reason or the coarse type.

reason parent type
:access_denied auth
:expired auth
:transport network (retryable)
:unavailable validation
:cancelled usage

Constant Summary collapse

REASON_TYPES =

Maps a device-flow reason to its parent OauthError type.

{
  access_denied: "auth",
  expired: "auth",
  transport: "network",
  unavailable: "validation",
  cancelled: "usage"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, message, http_status: nil, hint: nil) ⇒ DeviceFlowError

Returns a new instance of DeviceFlowError.

Parameters:

  • reason (Symbol)

    the device-flow termination reason

  • message (String)

    human-readable description

  • http_status (Integer, nil) (defaults to: nil)

    HTTP status code, if applicable

  • hint (String, nil) (defaults to: nil)

    helpful hint for resolving the error



34
35
36
37
38
39
40
41
42
43
# File 'lib/basecamp/oauth/device_flow_error.rb', line 34

def initialize(reason, message, http_status: nil, hint: nil)
  super(
    REASON_TYPES.fetch(reason, "api_error"),
    message,
    http_status: http_status,
    hint: hint,
    retryable: reason == :transport
  )
  @reason = reason
end

Instance Attribute Details

#reasonSymbol

the device-flow termination reason

Returns:

  • (Symbol)

    the current value of reason



18
19
20
# File 'lib/basecamp/oauth/device_flow_error.rb', line 18

def reason
  @reason
end