Exception: DeepL::Exceptions::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/deepl/exceptions/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, http_status_code: nil, should_retry: false) ⇒ Error

Returns a new instance of Error.

Parameters:

  • message (String, nil) (defaults to: nil)
  • http_status_code (Integer, nil) (defaults to: nil) —

    HTTP status of the failed response.

  • should_retry (Boolean) (defaults to: false) —

    Whether repeating the request may succeed.



15
16
17
18
19
# File 'lib/deepl/exceptions/error.rb', line 15

def initialize(message = nil, http_status_code: nil, should_retry: false)
  super(message)
  @http_status_code = http_status_code
  @should_retry = should_retry
end

Instance Attribute Details

#http_status_code ⇒ Integer? (readonly)

Returns HTTP status of the failed response, nil if there was none.

Returns:

  • (Integer, nil) —

    HTTP status of the failed response, nil if there was none.



10
11
12
# File 'lib/deepl/exceptions/error.rb', line 10

def http_status_code
  @http_status_code
end

Instance Method Details

#should_retry? ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/deepl/exceptions/error.rb', line 21

def should_retry?
  @should_retry || false
end