Module: RR::Errors

Defined in:
lib/rr/errors.rb,
lib/rr/errors/rr_error.rb,
lib/rr/errors/double_order_error.rb,
lib/rr/errors/times_called_error.rb,
lib/rr/errors/double_not_found_error.rb,
lib/rr/errors/double_definition_error.rb,
lib/rr/errors/subject_has_different_arity_error.rb,
lib/rr/errors/subject_does_not_implement_method_error.rb,
lib/rr/errors/spy_verification_errors/invocation_count_error.rb,
lib/rr/errors/spy_verification_errors/spy_verification_error.rb,
lib/rr/errors/spy_verification_errors/double_injection_not_found_error.rb

Defined Under Namespace

Modules: SpyVerificationErrors Classes: DoubleDefinitionError, DoubleNotFoundError, DoubleOrderError, RRError, SubjectDoesNotImplementMethodError, SubjectHasDifferentArityError, TimesCalledError

Constant Summary collapse

BACKTRACE_IDENTIFIER =
Regexp.new("/lib/rr")

Class Method Summary collapse

Class Method Details

.build_error(given_error, message = nil, backtrace = nil) ⇒ Object



7
8
9
10
11
12
# File 'lib/rr/errors.rb', line 7

def self.build_error(given_error, message = nil, backtrace = nil)
  error_class = self.error_class(given_error)
  error = message ? error_class.new(message) : error_class.new
  error.backtrace = backtrace if error_class < RR::Errors::RRError
  error
end

.error_class(given_error) ⇒ Object



14
15
16
17
18
19
# File 'lib/rr/errors.rb', line 14

def self.error_class(given_error)
  RR.overridden_error_class ||
  (given_error.is_a?(Symbol) ?
    RR::Errors.const_get(given_error) :
    given_error)
end