First, we handle the exception conditionally based /not/ on the
exception itself, but whether we have an exception handle installed
to deal with it. Is it valid to not use a when/default chain in CATCH
or to change topic, using: $_ = $my_new_topic. ?
An example of that would be helpful.
My second point involves re-throwing errors with useful stack traces.
Here's an example similar to what we do in CGI::App:
try { boom(); }
if ($!) {
die "died trying: $!"
}
I haven't seen the nice stack traces that pugs generate on death
mentioned in the spec. I think it's OK that this isn't mandatory for
Perl 6 implementations, but for those that do offer it, I suggest it
be spec'ed how to access the stack trace that is generated.
The above example would currently give a trace from where the re-throw
happened, but I really just want to enhance the message that was
originally generated. I want something like:
die "died trying: "~$!.stack_trace;
Without this, I'm currently worse off trying to handle and re-throw
errors, because the pugs CATCH implementation isn't complete, and using
the above recipe, all the errors are traced to the same unhelpful
location.
Mark
######
if ($@) {
my $error = $@;
$self->call_hook('error', $error);
if (my $em = $self->error_mode) {
$body = $self->$em( $error );
} else {
croak "Error executing run mode '$rm': $error" ;
}
}