Module: Core::Service::ErrorHandling

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

Defined Under Namespace

Modules: Helpers

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/api/core/service/error_handling.rb', line 2

def self.registered(app)
  app.instance_eval do
    helpers Helpers

    error(
      ::IllegalOperation,
      ::Core::Service::Error,
      ActiveRecord::ActiveRecordError,
      ActiveModel::ValidationError
    ) do
      buffer = [exception_thrown.message, exception_thrown.backtrace].join("\n")
      Rails.logger.error("API[error]: #{buffer}")
      exception_thrown.api_error(self)
    end
    error(StandardError) do
      buffer = [exception_thrown.message, exception_thrown.backtrace].join("\n")
      Rails.logger.error("API[error]: #{buffer}")
      general_error(501)
    end
  end
end