Exception: DeepL::Exceptions::RequestError
- Defined in:
- lib/deepl/exceptions/request_error.rb
Direct Known Subclasses
AuthorizationFailed, BadRequest, LimitExceeded, NotFound, QuotaExceeded, RequestEntityTooLarge, ServerError
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Attributes inherited from Error
Instance Method Summary collapse
-
#initialize(response, request = nil) ⇒ RequestError
constructor
A new instance of RequestError.
- #to_s ⇒ Object
Methods inherited from Error
Constructor Details
#initialize(response, request = nil) ⇒ RequestError
Returns a new instance of RequestError.
11 12 13 14 15 16 |
# File 'lib/deepl/exceptions/request_error.rb', line 11 def initialize(response, request = nil) super() @response = response @request = request @http_status_code = response.code.to_i if response.respond_to?(:code) end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
9 10 11 |
# File 'lib/deepl/exceptions/request_error.rb', line 9 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
9 10 11 |
# File 'lib/deepl/exceptions/request_error.rb', line 9 def response @response end |
Instance Method Details
#to_s ⇒ Object
18 19 20 21 22 |
# File 'lib/deepl/exceptions/request_error.rb', line 18 def to_s = status = "HTTP status #{http_status_code}" ? "Request failed with #{status}: #{}" : "Request failed with #{status}." end |