Class: HatiJsonapiError::Helpers::ApiErr

Inherits:
Object
  • Object
show all
Defined in:
lib/hati_jsonapi_error/helpers.rb

Overview

shorthand for API errors raise ApiErr # => ApiError::NotFound raise ApiErr # => ApiError::NotFound

Class Method Summary collapse

Class Method Details

.[](error) ⇒ Object



59
60
61
# File 'lib/hati_jsonapi_error/helpers.rb', line 59

def [](error)
  call(error)
end

.call(error) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/hati_jsonapi_error/helpers.rb', line 63

def call(error)
  raise HatiErrs::NotLoadedError unless HatiJsonapiError::Kigen.loaded?

  err = HatiJsonapiError::Kigen.fetch_err(error)

  unless err
    msg = "Error #{error} not defined on load_errors!. Check kigen.rb and api_error/error_const.rb"
    raise HatiErrs::NotDefinedErrorClassError, msg
  end

  err
end