Module: Brut::Framework::Errors

Included in:
CLI::Command, App, Brut::FrontEnd::Component, Brut::FrontEnd::Handler, Brut::FrontEnd::RouteHook
Defined in:
lib/brut/framework/errors.rb

Overview

Namespace for Brut-specific error classes, and a holder of several error-related convienience methods. Include this module to gain access to those methods.

Defined Under Namespace

Classes: AbstractMethod, Bug, MissingConfiguration, MissingParameter, NoClassForPath, NotFound, NotImplemented

Instance Method Summary collapse

Instance Method Details

#abstract_method!(method_name = nil) ⇒ Object

Raises AbstractMethod, which is useful if you need to document a method that a subclass must implement, but for which there is no useful default implementation.

Parameters:

  • method_name (String|Symbol) (defaults to: nil)

    name of the method that must be implemented. If omitted, the value is guessed from caller_locations

Raises:



32
33
34
35
# File 'lib/brut/framework/errors.rb', line 32

def abstract_method!(method_name=nil)
  method_name ||= caller_locations(1,1)[0].label
  raise Brut::Framework::Errors::AbstractMethod.new(method_name)
end

#bug!(message = nil) ⇒ Object

Raises Bug, used to indicate a codepath is a bug. "But, why write a bug in the first place?" you may be asking. Sometimes, a code path exists, but external factors mean that it should never be executed. Or, sometimes an API can be mis-used, but the current state of the system is such that it would never be misused.

This method allows you to indicate such situations and provide a meaningful explanation.

Parameters:

  • message (defaults to: nil)

    Message to include in the error

Raises:



22
23
24
# File 'lib/brut/framework/errors.rb', line 22

def bug!(message=nil)
  raise Brut::Framework::Errors::Bug,message
end