Exception: Seekmodo::Sdk::ClientError
- Inherits:
-
SeekmodoError
- Object
- StandardError
- SeekmodoError
- Seekmodo::Sdk::ClientError
- Defined in:
- lib/seekmodo/sdk/exceptions/client_error.rb
Direct Known Subclasses
OverQuotaError, SignatureMismatchError, TenantUnavailableError
Constant Summary collapse
- KIND_NOT_CONFIGURED =
"not_configured"- KIND_BREAKER_OPEN =
"breaker_open"- KIND_NETWORK =
"network"- KIND_TIMEOUT =
"timeout"- KIND_HTTP_4XX =
"http_4xx"- KIND_HTTP_5XX =
"http_5xx"- KIND_BAD_RESPONSE =
"bad_response"- KIND_SIGNATURE_MISMATCH =
"signature_mismatch"- KIND_RATE_LIMITED =
"rate_limited"- KIND_OVER_QUOTA =
"over_quota"- KIND_TENANT_UNAVAILABLE =
"tenant_unavailable"- TENANT_UNAVAILABLE_ERROR_CODES =
%w[ tenant_paused tenant_not_found tenant_unknown tenant_suspended tenant_disabled ].freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Class Method Summary collapse
Instance Method Summary collapse
- #error_code ⇒ Object
-
#initialize(message, kind, status_code = 0, body: nil, cause: nil) ⇒ ClientError
constructor
A new instance of ClientError.
- #is_transient? ⇒ Boolean
- #should_fallback? ⇒ Boolean
Constructor Details
#initialize(message, kind, status_code = 0, body: nil, cause: nil) ⇒ ClientError
Returns a new instance of ClientError.
26 27 28 29 30 31 32 |
# File 'lib/seekmodo/sdk/exceptions/client_error.rb', line 26 def initialize(, kind, status_code = 0, body: nil, cause: nil) super() @kind = kind @status_code = status_code @body = body || {} set_backtrace(cause&.backtrace) if cause end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
24 25 26 |
# File 'lib/seekmodo/sdk/exceptions/client_error.rb', line 24 def body @body end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
24 25 26 |
# File 'lib/seekmodo/sdk/exceptions/client_error.rb', line 24 def kind @kind end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
24 25 26 |
# File 'lib/seekmodo/sdk/exceptions/client_error.rb', line 24 def status_code @status_code end |
Class Method Details
.classify_error_code(error_code) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/seekmodo/sdk/exceptions/client_error.rb', line 52 def self.classify_error_code(error_code) return nil if error_code.nil? || error_code.empty? if TENANT_UNAVAILABLE_ERROR_CODES.include?(error_code) return KIND_TENANT_UNAVAILABLE end return KIND_SIGNATURE_MISMATCH if error_code == "signature_mismatch" return KIND_RATE_LIMITED if error_code == "rate_limited" return KIND_OVER_QUOTA if %w[over_quota feature_not_in_plan].include?(error_code) nil end |
Instance Method Details
#error_code ⇒ Object
47 48 49 50 |
# File 'lib/seekmodo/sdk/exceptions/client_error.rb', line 47 def error_code err = body["error"] err.is_a?(String) ? err : nil end |
#is_transient? ⇒ Boolean
34 35 36 37 38 39 40 41 |
# File 'lib/seekmodo/sdk/exceptions/client_error.rb', line 34 def is_transient? [ KIND_NETWORK, KIND_TIMEOUT, KIND_HTTP_5XX, KIND_TENANT_UNAVAILABLE ].include?(kind) end |
#should_fallback? ⇒ Boolean
43 44 45 |
# File 'lib/seekmodo/sdk/exceptions/client_error.rb', line 43 def should_fallback? kind != KIND_HTTP_4XX end |