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



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

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

#error_metaObject



111
112
113
# File 'lib/jsonapionify/api/resource/error_handling.rb', line 111

def error_meta
  errors.meta
end

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



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

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

#haltObject



115
116
117
118
119
# File 'lib/jsonapionify/api/resource/error_handling.rb', line 115

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

#set_errors(collection) ⇒ Object



107
108
109
# File 'lib/jsonapionify/api/resource/error_handling.rb', line 107

def set_errors(collection)
  errors.set collection
end