NAME
Bio::NEXUS::Util::Exceptions - Exception classes for Bio::NEXUS.
SYNOPSIS
use Bio::NEXUS::Node;
my $node = Bio::NEXUS::Node->new;
# now let's try something illegal
eval {
$node->set_branch_length( 'non-numerical value' );
};
# have an error
if ( $@ && UNIVERSAL::isa( $@, 'Bio::NEXUS::Util::Exception' ) ) {
# print out where the error came from
print $@->trace->as_string;
}
DESCRIPTION
Sometimes, Bio::NEXUS dies. If this happens because you did something that brought Bio::NEXUS into an undefined and dangerous state (such as might happen if you provide a non-numerical value for a setter that needs numbers), Bio::NEXUS will throw an "exception", a special form of the $@
variable that is a blessed object with useful methods to help you diagnose the problem.
This package defines the exceptions that can be thrown by Bio::NEXUS. There are no serviceable parts inside. Refer to the Exception::Class perldoc for more examples on how to catch exceptions and show traces.
AUTHORS
Original conception by Rutger Vos.
EXCEPTION CLASSES
- Bio::NEXUS::Util::Exceptions::BadNumber
-
Thrown when anything other than a number that passes Scalar::Util's looks_like_number test is given as an argument to a method that expects a number.
- Bio::NEXUS::Util::Exceptions::BadString
-
Thrown when a string that contains any of the characters
():;,
is given as an argument to a method that expects a name. - Bio::NEXUS::Util::Exceptions::BadFormat
-
Thrown when a file format error is encountered (e.g. unknown or invalid format).
- Bio::NEXUS::Util::Exceptions::OddHash
-
Thrown when an odd number of arguments has been specified. This might happen if you call a method that requires named arguments and the key/value pairs don't seem to match up.
- Bio::NEXUS::Util::Exceptions::ObjectMismatch
-
Thrown when a method is called that requires an object as an argument, and the wrong type of object is specified.
- Bio::NEXUS::Util::Exceptions::UnknownMethod
-
Thrown when an unknown method is called (e.g. through AUTOLOAD).
- Bio::NEXUS::Util::Exceptions::BadArgs
-
Thrown when something undefined is wrong with the supplied arguments.
- Bio::NEXUS::Util::Exceptions::FileError
-
Thrown when a file specified as an argument does not exist or is not readable.
- Bio::NEXUS::Util::Exceptions::ExtensionError
-
Thrown when there is an error loading a requested extension.
- Bio::NEXUS::Util::Exceptions::OutOfBounds
-
Thrown when an index is supplied that falls outside of an allowed range.
- Bio::NEXUS::Util::Exceptions::NotImplemented
-
Thrown when an interface method is called instead of the implementation by the child class.
- Bio::NEXUS::Util::Exceptions::Deprecated
-
Thrown when a deprecated method is called.
METHODS
- new()
-
Constructor
Type : Constructor Title : new Usage : $class->new( error => 'An exception was thrown!' ); Function: Constructs exception Returns : A Bio::NEXUS::Util::Exceptions object Args : error => 'Error message'
- throw()
-
Throws exception.
Type : Exception Title : throw Usage : $class->throw( error => 'An exception was thrown!' ); Function: Throws exception Returns : A Bio::NEXUS::Util::Exceptions object Args : error => 'Error message'
- caught()
-
Catches an exception by class.
Type : Handler Title : caught Usage : my $e = Bio::NEXUS::Util::Exceptions->caught; Function: Catches an exception Returns : A Bio::NEXUS::Util::Exceptions object Args : None
- rethrow()
-
Rethrows a caught exception.
Type : Exception Title : rethrow Usage : $@->rethrow; Function: Rethrows exception Returns : A Bio::NEXUS::Util::Exceptions object Args : None
- as_string()
-
Serializes exception.
Type : Serializer Title : as_string Usage : print $@->as_string; Function: Serializes exception with description and stack trace. Returns : String Args : None
REVISION
$Id: Exceptions.pm,v 1.5 2012/02/07 21:49:27 astoltzfus Exp $