Sha256: 6716d078c5e15319f96e64482e44b0c24066bf4b0c813b757dd6392ceb51672c
Contents?: true
Size: 776 Bytes
Versions: 2
Compression:
Stored size: 776 Bytes
Contents
# frozen_string_literal: true module DeepL module Utils class ExceptionBuilder attr_reader :request, :response 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 def initialize(request, response) @request = request @response = response end def build error_class = ERROR_CODE_CLASS_MAP[response.code.to_s] || Exceptions::RequestError error_class.new(request, response) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
deepl-rb-2.5.3 | lib/deepl/utils/exception_builder.rb |
deepl-rb-2.5.2 | lib/deepl/utils/exception_builder.rb |