module Eve::Errors

Constants

API_ERROR_MAP

Public Class Methods

find_by_code(code) click to toggle source

Returns an error class by its code. If a match cannot be found, the closest match is used instead. For instance, ‘100’ returns WalletNotLoaded; ‘199’ returns UserInputError.

# File lib/eve/errors.rb, line 11
def find_by_code(code)
  return API_ERROR_MAP[code.to_i] if API_ERROR_MAP.key?(code.to_i)
  # exact match can't be found, look for x's
  code = code.to_s
  while code.length > 0
    generic_code = code + "x"*(3-code.length)
    return API_ERROR_MAP[generic_code] if API_ERROR_MAP.key?(generic_code)
    code = code[0...-1]
  end
  UnknownError
end
raise(*several_variants) click to toggle source
Calls superclass method
# File lib/eve/errors.rb, line 23
def raise(*several_variants)
  options = several_variants.extract_options!
  super if options.empty?
  if options[:code]
    klass = find_by_code(options[:code])
    message = options[:message]
    raise klass, message, caller
  end
end