Exception: HandleSystem::Error

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

Overview

A basic Exception class to wrap the handle server errors

Author:

  • David Walker

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_code, message) ⇒ Error

New Handle server Error

Parameters:

  • response_code (Integer)

    handle protocol response code for the message

  • message (String)

    error message



25
26
27
28
# File 'lib/handle_system/exceptions.rb', line 25

def initialize(response_code, message)
  @response_code = response_code.to_int unless response_code.nil?
  super(message)
end

Instance Attribute Details

#handleString

Returns the handle specified in the request.

Returns:

  • (String)

    the handle specified in the request



14
15
16
# File 'lib/handle_system/exceptions.rb', line 14

def handle
  @handle
end

#response_codeIntenger (readonly)

Returns handle protocol response code for the message.

Returns:

  • (Intenger)

    handle protocol response code for the message



11
12
13
# File 'lib/handle_system/exceptions.rb', line 11

def response_code
  @response_code
end

#urlString

Returns the URL we sent that produced the error.

Returns:

  • (String)

    the URL we sent that produced the error



17
18
19
# File 'lib/handle_system/exceptions.rb', line 17

def url
  @url
end

Class Method Details

.response_codesHash

Handle server response codes / description

Returns:

  • (Hash)

    in the form of code => description



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/handle_system/exceptions.rb', line 35

def self.response_codes
  {
    2 => 'An unexpected error on the server',
    100 => 'Handle not found',
    101 => 'Handle already exists',
    102 => 'Invalid handle',
    200 => 'Values not found',
    201 => 'Value already exists',
    202 => 'Invalid value',
    301 => 'Server not responsible for handle',
    402 => 'Authentication needed'
  }
end