Exception: LicenseKit::ApiError
- Inherits:
-
StandardError
- Object
- StandardError
- LicenseKit::ApiError
- Defined in:
- lib/licensekit/errors.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status:, code:, message:, detail: nil, request_id: nil, timestamp: nil, body: nil) ⇒ ApiError
constructor
A new instance of ApiError.
Constructor Details
#initialize(status:, code:, message:, detail: nil, request_id: nil, timestamp: nil, body: nil) ⇒ ApiError
Returns a new instance of ApiError.
5 6 7 8 9 10 11 12 13 |
# File 'lib/licensekit/errors.rb', line 5 def initialize(status:, code:, message:, detail: nil, request_id: nil, timestamp: nil, body: nil) super() @status = status @code = code @detail = detail @request_id = request_id @timestamp = @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/licensekit/errors.rb', line 3 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/licensekit/errors.rb', line 3 def code @code end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
3 4 5 |
# File 'lib/licensekit/errors.rb', line 3 def detail @detail end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
3 4 5 |
# File 'lib/licensekit/errors.rb', line 3 def request_id @request_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/licensekit/errors.rb', line 3 def status @status end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/licensekit/errors.rb', line 3 def @timestamp end |
Class Method Details
.from_response(status, body) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/licensekit/errors.rb', line 15 def self.from_response(status, body) envelope = LicenseKit.parse_error_envelope(body) return new(status: status, code: "UNKNOWN_ERROR", message: "Request failed with status #{status}", body: body) if envelope.nil? = envelope["meta"] || {} new( status: status, code: envelope["error"]["code"], message: envelope["error"]["message"], detail: envelope["error"]["detail"], request_id: ["request_id"], timestamp: ["timestamp"], body: body ) end |