Exception: FaithTeams::API::V2::Error::Request
- Inherits:
-
StandardError
- Object
- StandardError
- FaithTeams::API::V2::Error::Request
- Defined in:
- lib/faithteams/api/v2/error/request.rb
Overview
A request failed to complete successfully.
Constant Summary collapse
- UNAUTHORIZED_ERROR_MESSAGE =
Custom faithteams error about invalid API key
"Unauthorized"- NOT_FOUND_ERROR_MESSAGE =
Custom faithteams error when a resource is not found
"Not Found"
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #failure_message ⇒ String
-
#initialize(response:, message: "Request failed", skip_failure_message: false) ⇒ Request
constructor
A new instance of Request.
- #not_found? ⇒ Boolean
- #unauthorized? ⇒ Boolean
Constructor Details
#initialize(response:, message: "Request failed", skip_failure_message: false) ⇒ Request
Returns a new instance of Request.
19 20 21 22 23 |
# File 'lib/faithteams/api/v2/error/request.rb', line 19 def initialize(response:, message: "Request failed", skip_failure_message: false) @response = response += ": #{}" unless .blank? || super() end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
9 10 11 |
# File 'lib/faithteams/api/v2/error/request.rb', line 9 def response @response end |
Instance Method Details
#failure_message ⇒ String
26 27 28 29 30 31 |
# File 'lib/faithteams/api/v2/error/request.rb', line 26 def @failure_message ||= response.parse(:json).dig("message") rescue "" rescue JSON::ParserError => e e.capture response.to_s end |
#not_found? ⇒ Boolean
39 40 41 |
# File 'lib/faithteams/api/v2/error/request.rb', line 39 def not_found? == NOT_FOUND_ERROR_MESSAGE end |
#unauthorized? ⇒ Boolean
34 35 36 |
# File 'lib/faithteams/api/v2/error/request.rb', line 34 def == UNAUTHORIZED_ERROR_MESSAGE end |