LINQ::Exception - exceptions thrown by LINQ
When LINQ encounters an error, it doesn't just die with a string, but throws an exception object which can be caught with eval, Try::Tiny, or Syntax::Keyword::Try.
die
eval
These objects overload stringification, so if they are not caught and dealt with, you'll get a sensible error message printed.
This is the base class for all LINQ exceptions.
use LINQ qw( LINQ ); use Syntax::Keyword::Try qw( try :experimental ); try { my $collection = LINQ [ 1, 2, 3 ]; my $item = $collection->element_at( 10 ); } catch ( $e isa LINQ::Exception ) { printf( "Got error: %s at %s (%s line %d)\n", $e->message, $e->package, $e->file, $e->line, ); }
The class provides message, package, file, and line methods to get details of the error, as well as a to_string method which provides the message, package, file, and line as one combined string.
message
package
file
line
to_string
There is a class method throw which instantiates a new object and dies.
throw
'LINQ::Exception'->throw;
LINQ::Exception is never directly thrown by LINQ, but subclasses of it are.
A subclass of LINQ::Exception thrown when you call a method or feature which is not implemented for the collection you call it on.
A subclass of LINQ::Exception thrown when an internal error is encountered in LINQ, not caused by the caller.
A subclass of LINQ::Exception thrown when the caller of a method has called it incorrectly. For example, if a method is called which expects a coderef as a parameter, but is given a string.
A subclass of LINQ::Exception thrown when a method you've called cannot be fulfilled by the collection you've called it on. For example, you've asked to fetch the third item in a collection containing only two items.
The exception has a collection attribute which returns the collection which generated the error.
collection
A subclass of LINQ::Exception::CollectionError thrown when trying to access an item in a collection which cannot be found.
A subclass of LINQ::Exception::CollectionError thrown when trying to access a single item in a collection when multiple items are found.
A subclass of LINQ::Exception::CollectionError thrown when trying to cast all items in a collection to a type, but this fails for one or more items.
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=LINQ.
LINQ.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2014, 2021 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install LINQ, copy and paste the appropriate command in to your terminal.
cpanm
cpanm LINQ
CPAN shell
perl -MCPAN -e shell install LINQ
For more information on module installation, please visit the detailed CPAN module installation guide.