Error-Hierarchy

 view release on metacpan or  search on metacpan

lib/Error/Hierarchy/Mixin.pm  view on Meta::CPAN

BEGIN {
  $Error::Hierarchy::Mixin::VERSION = '1.103530';
}
# ABSTRACT: Provides often-used exception-related methods
use Error;    # to get $Error::Depth

BEGIN {
    *CORE::GLOBAL::die = sub (@) {

        # Error.pm die()s as well, but we don't want an endless recursion.
        CORE::die(@_) if (caller)[0] eq 'Error' || ref $_[0];
        local $Error::Depth = $Error::Depth + 1;    # skip this level
        throw Error::Hierarchy::Internal::CustomMessage(
            custom_message => join(' ', @_),);
    };
}

# Any class that wants to throw an exception can simply use or inherit from
# this module and call 'throw Error::Whatever' without having to 'require' it
# first. By putting the throw() method in UNIVERSAL:: we catch method calls on
# exception classes that haven't been loaded yet. We load the class, then



( run in 1.743 second using v1.01-cache-2.11-cpan-1e74a51a04c )