Module: Core::Service::Error::Behaviour

Included in:
ActiveRecord::ActiveRecordError, Core::Service::Error, IllegalOperation
Defined in:
app/api/core/service.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


8
9
10
11
12
13
14
15
# File 'app/api/core/service.rb', line 8

def self.included(base)
  base.class_eval do
    class_attribute :api_error_code
    class_attribute :api_error_message
    alias_method :api_error_message, :message
    self.api_error_code = 500
  end
end

Instance Method Details

#api_error(response) ⇒ Object


17
18
19
# File 'app/api/core/service.rb', line 17

def api_error(response)
  response.general_error(self.class.api_error_code, [self.class.api_error_message || api_error_message])
end