Class: Kameleoon::Events::HttpRequestFailure
- Inherits:
-
Object
- Object
- Kameleoon::Events::HttpRequestFailure
- Defined in:
- lib/kameleoon/events/http_request_failure.rb
Overview
Describes the failure of an SDK HTTP request reported to HttpRequestHandler.
Defined Under Namespace
Modules: Reason
Instance Attribute Summary collapse
-
#cause ⇒ Exception?
readonly
The exception caused the failure.
-
#http_status ⇒ Integer?
readonly
The HTTP status code of the response.
-
#reason ⇒ Symbol
readonly
The reason of the failure, one of the
Reasonconstants.
Class Method Summary collapse
- .from_exception(cause) ⇒ Object private
- .from_http_status(http_status) ⇒ Object private
- .of_cancellation ⇒ Object private
Instance Method Summary collapse
-
#initialize(reason, http_status, cause) ⇒ HttpRequestFailure
constructor
A new instance of HttpRequestFailure.
- #to_s ⇒ Object
Constructor Details
#initialize(reason, http_status, cause) ⇒ HttpRequestFailure
Returns a new instance of HttpRequestFailure.
55 56 57 58 59 |
# File 'lib/kameleoon/events/http_request_failure.rb', line 55 def initialize(reason, http_status, cause) @reason = reason @http_status = http_status @cause = cause end |
Instance Attribute Details
#cause ⇒ Exception? (readonly)
Returns The exception caused the failure. Not nil only if
reason is Reason::EXCEPTION.
33 34 35 |
# File 'lib/kameleoon/events/http_request_failure.rb', line 33 def cause @cause end |
#http_status ⇒ Integer? (readonly)
Returns The HTTP status code of the response. Not nil only if
reason is Reason::HTTP_STATUS.
29 30 31 |
# File 'lib/kameleoon/events/http_request_failure.rb', line 29 def http_status @http_status end |
#reason ⇒ Symbol (readonly)
Returns The reason of the failure, one of the Reason constants.
25 26 27 |
# File 'lib/kameleoon/events/http_request_failure.rb', line 25 def reason @reason end |
Class Method Details
.from_exception(cause) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 |
# File 'lib/kameleoon/events/http_request_failure.rb', line 41 def self.from_exception(cause) new(Reason::EXCEPTION, nil, cause) end |
.from_http_status(http_status) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/kameleoon/events/http_request_failure.rb', line 36 def self.from_http_status(http_status) new(Reason::HTTP_STATUS, http_status, nil) end |
Instance Method Details
#to_s ⇒ Object
50 51 52 53 |
# File 'lib/kameleoon/events/http_request_failure.rb', line 50 def to_s "HttpRequestFailure{reason:#{@reason},http_status:#{@http_status || 'nil'}," \ "cause:#{@cause.nil? ? 'nil' : @cause.class}}" end |