Class: Honeybadger::Backend::Response Private
- Inherits:
-
Object
- Object
- Honeybadger::Backend::Response
- Defined in:
- lib/honeybadger/backend/base.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Constant Summary collapse
- NOT_BLANK =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/\S/
- FRIENDLY_ERRORS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 429 => "Your project is currently sending too many errors.\nThis issue should resolve itself once error traffic is reduced.".freeze, 503 => "Your project is currently sending too many errors.\nThis issue should resolve itself once error traffic is reduced.".freeze, 402 => "The project owner's billing information has expired (or the trial has ended).\nPlease check your payment details or email [email protected] for help.".freeze, 403 => "The API key is invalid. Please check your API key and try again.".freeze, 413 => "The payload is too large.".freeze }.freeze
Instance Attribute Summary collapse
- #body ⇒ Object readonly private
- #code ⇒ Object readonly private
- #error ⇒ Object readonly private
- #message ⇒ Object readonly private
Instance Method Summary collapse
- #error_message ⇒ Object private
-
#initialize(*args) ⇒ Response
constructor
private
Initializes the Response instance.
- #success? ⇒ Boolean private
Constructor Details
#initialize(response) ⇒ Response #initialize(code, body, message) ⇒ Response
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.
Initializes the Response instance.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/honeybadger/backend/base.rb', line 36 def initialize(*args) if (response = args.first).kind_of?(Net::HTTPResponse) @code, @body, @message = response.code.to_i, response.body.to_s, response. else @code, @body, @message = args end @success = (200..299).cover?(@code) @error = parse_error(body) unless @success end |
Instance Attribute Details
#body ⇒ Object (readonly)
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.
12 13 14 |
# File 'lib/honeybadger/backend/base.rb', line 12 def body @body end |
#code ⇒ Object (readonly)
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.
12 13 14 |
# File 'lib/honeybadger/backend/base.rb', line 12 def code @code end |
#error ⇒ Object (readonly)
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.
12 13 14 |
# File 'lib/honeybadger/backend/base.rb', line 12 def error @error end |
#message ⇒ Object (readonly)
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.
12 13 14 |
# File 'lib/honeybadger/backend/base.rb', line 12 def @message end |
Instance Method Details
#error_message ⇒ 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.
51 52 53 54 55 56 57 58 |
# File 'lib/honeybadger/backend/base.rb', line 51 def return if code == :error return FRIENDLY_ERRORS[code] if FRIENDLY_ERRORS[code] return error if error =~ NOT_BLANK msg = "The server responded with #{code}" msg << ": #{}" if =~ NOT_BLANK msg end |
#success? ⇒ Boolean
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.
47 48 49 |
# File 'lib/honeybadger/backend/base.rb', line 47 def success? @success end |