Class: Uplink::ErrorUtil

Inherits:
Object
  • Object
show all
Defined in:
lib/uplink/error_util.rb

Class Method Summary collapse

Class Method Details

.handle_error(error) ⇒ Object

Raises:

  • (err)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/uplink/error_util.rb', line 10

def handle_error(error)
  return 0 if error.null?

  error_code = error[:code]
  return error_code if error_code == EOF

  err = CODE_TO_ERROR_MAPPING[error_code]
  raise err.new(error_code, error[:message]) if err

  raise InternalError.new(error_code, error[:message])
end

.handle_result_error(result) ⇒ Object



6
7
8
# File 'lib/uplink/error_util.rb', line 6

def handle_result_error(result)
  handle_error(result[:error])
end