Module: JSONAPIonify::Api::Resource::ErrorHandling

Extended by:
ActiveSupport::Concern
Included in:
JSONAPIonify::Api::Resource
Defined in:
lib/jsonapionify/api/resource/error_handling.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#error(name, *args, &block) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/jsonapionify/api/resource/error_handling.rb', line 87

def error(name, *args, &block)
  errors.evaluate(
    *args,
    error_block:   lookup_error(name),
    runtime_block: block
  )
end

#error_metaObject



104
105
106
# File 'lib/jsonapionify/api/resource/error_handling.rb', line 104

def error_meta
  errors.meta
end

#error_now(name, *args, &block) ⇒ Object



95
96
97
98
# File 'lib/jsonapionify/api/resource/error_handling.rb', line 95

def error_now(name, *args, &block)
  error(name, *args, &block)
  halt
end

#haltObject



108
109
110
111
112
# File 'lib/jsonapionify/api/resource/error_handling.rb', line 108

def halt
  error = Errors::RequestError.new
  error.set_backtrace caller
  raise error
end

#set_errors(collection) ⇒ Object



100
101
102
# File 'lib/jsonapionify/api/resource/error_handling.rb', line 100

def set_errors(collection)
  errors.set collection
end