Exception: RubyTCC::Error

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

Overview

Custom error class for rescuing from all RubyTCC errors

Constant Summary collapse

ConfigurationError =
Class.new(::ArgumentError)
ClientError =

Raised when RubyTCC returns a 4xx HTTP status code

Class.new(self)
RequestTimeout =

Raised when RubyTCC returns the HTTP status code 408

Class.new(ClientError)
ResultError =

Raised when the result is not “Success”

Class.new(self)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = '', code = nil) ⇒ RubyTCC::Error

Initializes a new Error object

Parameters:

  • message (Exception, String) (defaults to: '')
  • code (Integer) (defaults to: nil)


44
45
46
47
# File 'lib/rubytcc/error.rb', line 44

def initialize(message = '', code = nil)
  super(message)
  @code = code
end

Instance Attribute Details

#codeInteger (readonly)

Returns:

  • (Integer)


5
6
7
# File 'lib/rubytcc/error.rb', line 5

def code
  @code
end

Class Method Details

.from_response(response) ⇒ RubyTCC::Error

Create a new error from an HTTP response

Parameters:

  • response (RestClient::Response)

Returns:



12
13
14
15
# File 'lib/rubytcc/error.rb', line 12

def from_response(response)
  message, code = parse_error(response.body)
  new(message, response.response_headers, code)
end