26 Jan 2021 07:56:30 UTC
- Distribution: Language-FormulaEngine
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (0)
- Testers (138 / 1 / 0)
- KwaliteeBus factor: 1
- 80.84% Coverage
- License: perl_5
- Activity24 month
- Download (39.73KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
- EXPORTABLE FUNCTIONS
- COPYRIGHT AND LICENSE
Language::FormulaEngine::Error - Exception objects for formula functions
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
This wraps the error in a "landmine". Any perl code that attempts to operate on the value of the object will instead die with
disarmon the mine to return the original
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 <email@example.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.
Module Install Instructions
To install Language::FormulaEngine, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Language::FormulaEngine
For more information on module installation, please visit the detailed CPAN module installation guide.