module LunaPark::Extensions::HasErrors::InstanceMethods

Public Instance Methods

error(title, msg = nil, **attrs) click to toggle source

Raise error defined in class

@example

class Service
  include LunaPark::Extensions::HasErrors

  class CustomError < LunaPark::Errors::Business; end
end

Service.new.error :custom_error # => raise CustomError

@param title [Symbol|String] - Title of error @param msg [String] - Message of error @param **attrs - See @LunaPark::Errors::Base#new

# File lib/luna_park/extensions/has_errors.rb, line 54
def error(title, msg = nil, **attrs)
  class_name = self.class.error_class_name(title)
  raise self.class.const_get(class_name).new msg, **attrs
end