NAME
Language::FormulaEngine::Error - Exception objects for formula functions
VERSION
version 0.08
DESCRIPTION
In keeping with the theme of spreadsheet formulas, this module collection provides exception objects that can be used for similar exception handling. These objects are intended to be thrown using "die", but they can also be wrapped with a "trap" object so that they don't die until used. For example, in a spreadsheet the error is returned from a function, but anything that uses that value needs to generate a similar error. That would require a lot of argument checking and prevent using native Perl operations, but by returning an error wrapped in a trap, any perl operation that attempts to use the trap will instead throw the exception object.
ATTRIBUTES
All error objects have:
message
A text description of the error
METHODS
mine
return $error->mine;
This wraps the error in a "landmine". Any perl code that attempts to operate on the value of the object will instead die with $error
. Call disarm
on the mine to return the original $error
reference.
EXPORTABLE FUNCTIONS
Each of the sub-classes of error has a constructor function which you can export from this module. You can also take a perl-generated exception and automatically wrap it with an appropriate Error object using "auto_wrap_error".
ErrInval
The formula was given invalid inputs
ErrNA
The function encountered a condition where no value could be returned. i.e. the function is not defined for the supplied parameters, such as accessing elements beyond the end of an array.
ErrREF
The formula referenced a non-existent or nonsensical variable.
ErrNUM
The function expected a number (or specific range of number, like positive, integer, etc) but was given something it couldn't convert.
ErrNAME
The formula uses an unknown function name. This is thrown during compilation, or during evaluation if the compile step is omitted.
auto_wrap_error
my $err_obj= auto_wrap_error( $perl_error_text );
Look at the perl error to see if it is a known type of error, and wrap it with the appropriate type of error object.
AUTHOR
Michael Conrad <mconrad@intellitree.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2023 by Michael Conrad, IntelliTree Solutions llc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.