Module: LunaPark::Extensions::HasErrors

Included in:
UseCases::Scenario, UseCases::Service
Defined in:
lib/luna_park/extensions/has_errors.rb

Overview

This is syntax sugar for define exception class in UseCase layer

Examples:

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

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

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



33
34
35
36
# File 'lib/luna_park/extensions/has_errors.rb', line 33

def self.included(base)
  base.extend  ClassMethods
  base.include InstanceMethods
end