Module: Core::Service::ErrorHandling::Helpers

Defined in:
app/api/core/service/error_handling.rb

Defined Under Namespace

Classes: JsonError

Instance Method Summary collapse

Instance Method Details

#content_error(code, errors = nil) ⇒ Object


45
46
47
# File 'app/api/core/service/error_handling.rb', line 45

def content_error(code, errors = nil)
  error(code, JsonError.new(content: errors))
end

#exception_thrownObject


35
36
37
# File 'app/api/core/service/error_handling.rb', line 35

def exception_thrown
  @env['sinatra.error']
end

#general_error(code, errors = nil) ⇒ Object


39
40
41
42
43
# File 'app/api/core/service/error_handling.rb', line 39

def general_error(code, errors = nil)
  Rails.logger.error(exception_thrown.backtrace.join("\n"))
  errors ||= [exception_thrown.message]
  error(code, JsonError.new(general: errors))
end