Text::BSV::Exception - create an object that can be thrown using the Perl "die" function (which can accept a reference instead of a string) and caught using "eval", which stores the object in $EVAL_ERROR ($@).
use Text::BSV::Exception; my $exception = Text::BSV::Exception->new($Text::BSV::Exception::GENERAL, "Couldn't do stuff because of the thing."); my $fancy_exception = Text::BSV::Exception->new( $Text::BSV::Exception::NULL_POINTER, "Couldn't do stuff because the thing was pointing to nothing.", {"IsFatal" => $TRUE, "Time" => "17:47:18"}); my $exception_type = $exception->get_type(); my $message_string = $exception->get_message(); my $hash_ref = $fancy_exception->get_data();
This module defines a package for creating a Text::BSV::Exception object, which can be thrown using the Perl "die" function and caught using "eval".
In addition to the class-name argument, which is passed in automatically when you use the Text::BSV::Exception->new() syntax, the constructor takes an exception type, a message string, and an optional hash reference that points to arbitrary structured data pertaining to the exception.
Text::BSV::Exception->new()
The exception type must be one of the following constants defined in the Text::BSV::Exception package:
$DIRECTORY_NOT_FOUND $FILE_NOT_FOUND $GENERAL $ILLEGAL_ARGUMENT $INVALID_CHARACTER $INVALID_DATA_FORMAT $INVALID_REGEX $IO_ERROR $NULL_POINTER $UNSUPPORTED_OPERATION
The constructor returns a reference to a Text::BSV::Exception object, which is implemented internally as a hash. All functionality is exposed through methods.
This module requires Perl 5, version 5.10.1 or later.
This is the constructor.
This is the accessor method for retrieving the exception type, which must be one of the following constants defined in the Text::BSV::Exception package:
This is the accessor method for retrieving the message.
This is the accessor method for retrieving any structured data provided with the exception. If there is no structured data, the get_data() method returns a reference to an empty hash.
get_data()
Benjamin Fitch, <blernflerkl@yahoo.com>
Copyright 2010 by Benjamin Fitch.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Text::BSV::Exception, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::BSV::Exception
CPAN shell
perl -MCPAN -e shell install Text::BSV::Exception
For more information on module installation, please visit the detailed CPAN module installation guide.