Just a thought, completely untested but should give you the idea:
I want to add some custom exception handling code to a dancer (loving it
so far!) app and am experimenting around.
eg:
use Dancer ':syntax';
use Try::Tiny;
get '/' => sub {
try {
my $data = process_data(); # throws Exception::Class objects
template 'index', {
'data' => $data,
};
}
catch {
my $exception = $_;
template 'error', {
'exception' => $exception,
};
};
return 1;
};
1;
This works, but I will have to duplicate the exception handling code for
every route. If "get" and the other route handlers were normal methods,
I would be able to subclass Dancer and add the exception handling code
that way. But since it is some kind of syntactic sugar, not sure if
that is easily doable. Any ideas?
Thanks.
--
Taric
_______________________________________________
Dancer-users mailing list
Dancer-users@perldancer.org
http://www.backup-manager.org/cgi-bin/listinfo/dancer-users