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



47
48
49
# File 'app/api/core/service/error_handling.rb', line 47

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

#exception_thrownObject



37
38
39
# File 'app/api/core/service/error_handling.rb', line 37

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

#general_error(code, errors = nil) ⇒ Object



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

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