I expected from TryCatch that it is possible that you can just catch any
classes with a type match. An example what i mean is given in: trycatch.pl
Here i expected that i can Fetch the object that is from the class
"Error" but it didn't work. This code just print some useless error message:
Show quoted text
> syntax error at ./trycatch.pl line 24, near "}
> {"
>Missing right curly or square bracket at ./trycatch.pl line 26, at end
of line
Show quoted text>Execution of ./trycatch.pl aborted due to compilation errors.
I spend a long debug time to find that it is not possible to fetch
non-Moose classes. If i commentet out "use Moose", then this code works.
It would be nice if this is possible. So somebody can even fetch lets
say "Exception::Class" Exceptions that not bassed on Moose.
By the way even if this is not possible or did not change. It would be
nice when this would be mentioned in the Documentation. A useful error
message instead of a syntax error would also be better.
Subject: | trycatch.pl |
#!/usr/bin/env perl
# Core Modules
use strict;
use warnings;
use utf8;
use open ':encoding(UTF-8)';
use open ':std';
use TryCatch;
BEGIN {
package Error;
sub new { bless {}, $_[0]}
use Moose;
}
my $t = Error->new;
sub error {
die bless {}, 'Error';
}
try {
error();
}
catch(Error $e) {
print "Error catched\n";
}