module LunaPark::Extensions::HasErrors

This is syntax sugar for define exception class in UseCase layer

@example without sugar

class Service
  class UserNotExists < LunaPark::Errors::Business
    message 'Sorry but user does not exists'
  end

  def call
     raise UserNotExists if something_wrong
  end
end

@example with sugar

class Service
  include LunaPark::Extensions::HasErrors
  error :user_not_exists, 'Sorry but user does not exists'

  def call
    error :user_not_exists if something_wrong
  end
end

Public Class Methods

included(base) click to toggle source
# File lib/luna_park/extensions/has_errors.rb, line 33
def self.included(base)
  base.extend  ClassMethods
  base.include InstanceMethods
end