Exception: Sendgo::SendgoError
- Inherits:
-
StandardError
- Object
- StandardError
- Sendgo::SendgoError
- Defined in:
- lib/sendgo/error.rb
Overview
Sendgo API 호출 실패 시 발생하는 에러.
Instance Attribute Summary collapse
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, status_code: 0, error_code: nil, endpoint: "", api_version: "", response_body: {}) ⇒ SendgoError
constructor
A new instance of SendgoError.
Constructor Details
#initialize(message, status_code: 0, error_code: nil, endpoint: "", api_version: "", response_body: {}) ⇒ SendgoError
Returns a new instance of SendgoError.
6 7 8 9 10 11 12 13 |
# File 'lib/sendgo/error.rb', line 6 def initialize(, status_code: 0, error_code: nil, endpoint: "", api_version: "", response_body: {}) super() @status_code = status_code @error_code = error_code @endpoint = endpoint @api_version = api_version @response_body = response_body end |
Instance Attribute Details
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
4 5 6 |
# File 'lib/sendgo/error.rb', line 4 def api_version @api_version end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
4 5 6 |
# File 'lib/sendgo/error.rb', line 4 def endpoint @endpoint end |
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
4 5 6 |
# File 'lib/sendgo/error.rb', line 4 def error_code @error_code end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
4 5 6 |
# File 'lib/sendgo/error.rb', line 4 def response_body @response_body end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
4 5 6 |
# File 'lib/sendgo/error.rb', line 4 def status_code @status_code end |
Class Method Details
.from_response(status, body, endpoint, api_version) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/sendgo/error.rb', line 15 def self.from_response(status, body, endpoint, api_version) error_code = body["code"] = body["message"] || "Unknown error" msg = "HTTP #{status}" msg += " [#{error_code}]" if error_code msg += " #{}" new(msg, status_code: status, error_code: error_code, endpoint: endpoint, api_version: api_version, response_body: body) end |