Class: DeepL::Utils::ExceptionBuilder
- Inherits:
-
Object
- Object
- DeepL::Utils::ExceptionBuilder
- Defined in:
- lib/deepl/utils/exception_builder.rb
Constant Summary collapse
- ERROR_CODE_CLASS_MAP =
{ '400' => Exceptions::BadRequest, '401' => Exceptions::AuthorizationFailed, '403' => Exceptions::AuthorizationFailed, '404' => Exceptions::NotFound, '413' => Exceptions::RequestEntityTooLarge, '429' => Exceptions::LimitExceeded, '456' => Exceptions::QuotaExceeded }.freeze
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(request, response) ⇒ ExceptionBuilder
constructor
A new instance of ExceptionBuilder.
Constructor Details
#initialize(request, response) ⇒ ExceptionBuilder
Returns a new instance of ExceptionBuilder.
18 19 20 21 |
# File 'lib/deepl/utils/exception_builder.rb', line 18 def initialize(request, response) @request = request @response = response end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/deepl/utils/exception_builder.rb', line 6 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/deepl/utils/exception_builder.rb', line 6 def response @response end |
Instance Method Details
#build ⇒ Object
23 24 25 26 |
# File 'lib/deepl/utils/exception_builder.rb', line 23 def build error_class = ERROR_CODE_CLASS_MAP[response.code.to_s] || Exceptions::RequestError error_class.new(request, response) end |