Language::FormulaEngine::Error - Exception objects for formula functions
version 0.06
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.
All error objects have:
A text description of the error
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.
$error
disarm
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".
The formula was given invalid inputs
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.
The formula referenced a non-existent or nonsensical variable.
The function expected a number (or specific range of number, like positive, integer, etc) but was given something it couldn't convert.
The formula uses an unknown function name. This is thrown during compilation, or during evaluation if the compile step is omitted.
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.
Michael Conrad <mconrad@intellitree.com>
This software is copyright (c) 2021 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.
To install Language::FormulaEngine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Language::FormulaEngine
CPAN shell
perl -MCPAN -e shell install Language::FormulaEngine
For more information on module installation, please visit the detailed CPAN module installation guide.