Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- No. I am not looking for one more Try Catch module.
- I am looking for possibility to catch errors rised up in Mojolicious::Routes::_dispatch_controller method in 415 .. 419 lines. Here are those lines:
- # Call action
- if($app->can($method)) {
- $stash->{'mojo.routed'} = 1 unless $staging;
- $continue = $app->dispatch($method); # XXX: changes !!!!!!!!!!!
- #$continue = $app->$method; # Original.
- }
- I have to wrap $app->$method call by "dispatch" function to catch error that rise up in the $method body.
- So the "dispatch" wrapper used to catch errors rised during the $method execution.
- I do not want to perform idiotic job wrapping every controller function body to catch errors.
- I want to have centrilized try catch decision.
- So I want to catch errors rised up in the controller before they catched by this block:
- # Controller error
- unless ($success) {
- my $e = Mojo::Exception->new($@);
- $c->app->log->error($e);
- $app->render_exception($e) if $app->can('render_exception');
- return $e;
- }
- May be it would be better to give to developers possibility to set the Exception class in MyApp.pm
- In that case "# Controller error" block will look like:
- # Controller error
- unless ($success) {
- my $excaptionPackage = $c->app->exceptionCLassName;
- my $e = $ExceptionPackage->new($@);
- $c->app->log->error($e);
- $app->render_exception($e) if $app->can('render_exception');
- return $e;
- }
Add Comment
Please, Sign In to add comment