Module: CommandTower::Workflows::Me::ErrorMapping

Defined in:
app/workflows/command_tower/workflows/me/error_mapping.rb

Overview

HTTP status mapping for Me/Account workflow failures. Includes phone (2.8) and pushover (host until 2.9) account errors.

Class Method Summary collapse

Class Method Details

.http_status_for(error) ⇒ Object



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 'app/workflows/command_tower/workflows/me/error_mapping.rb', line 11

def http_status_for(error)
  case error
  when CommandTower::Errors::ForbiddenError
    :forbidden
  when CommandTower::Errors::Auth::EmailVerificationRequiredError
    :precondition_failed
  when CommandTower::Errors::UnauthorizedError
    :unauthorized
  when CommandTower::Errors::Account::PhoneVerificationCodeInvalidError,
       CommandTower::Errors::Account::PhoneVerificationExpiredError,
       CommandTower::Errors::Account::PhoneVerificationStaleError,
       CommandTower::Errors::Account::PhoneMissingError,
       CommandTower::Errors::Account::PhoneAlreadyVerifiedError,
       CommandTower::Errors::Account::PushoverNotConfiguredError,
       CommandTower::Errors::Account::PushoverAlreadyConfiguredError,
       CommandTower::Errors::Account::PushoverVerificationFailedError,
       CommandTower::Errors::ValidationError
    :unprocessable_entity
  when CommandTower::Errors::Account::PhoneVerificationThrottledError
    :too_many_requests
  when CommandTower::Errors::Account::SmsCapabilityUnavailableError,
       CommandTower::Errors::Account::PushoverCapabilityUnavailableError
    :service_unavailable
  when CommandTower::Errors::Account::PhoneVerificationSendFailedError,
       CommandTower::Errors::Account::PushoverProviderUnavailableError
    :bad_gateway
  when CommandTower::Errors::InternalError
    :internal_server_error
  else
    :internal_server_error
  end
end