Guest User

Untitled

a guest
Dec 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. No. I am not looking for one more Try Catch module.
  2. I am looking for possibility to catch errors rised up in Mojolicious::Routes::_dispatch_controller method in 415 .. 419 lines. Here are those lines:
  3.  
  4. # Call action
  5. if($app->can($method)) {
  6. $stash->{'mojo.routed'} = 1 unless $staging;
  7. $continue = $app->dispatch($method); # XXX: changes !!!!!!!!!!!
  8. #$continue = $app->$method; # Original.
  9. }
  10. I have to wrap $app->$method call by "dispatch" function to catch error that rise up in the $method body.
  11. So the "dispatch" wrapper used to catch errors rised during the $method execution.
  12.  
  13. I do not want to perform idiotic job wrapping every controller function body to catch errors.
  14. I want to have centrilized try catch decision.
  15. So I want to catch errors rised up in the controller before they catched by this block:
  16.  
  17. # Controller error
  18. unless ($success) {
  19. my $e = Mojo::Exception->new($@);
  20. $c->app->log->error($e);
  21. $app->render_exception($e) if $app->can('render_exception');
  22. return $e;
  23. }
  24. May be it would be better to give to developers possibility to set the Exception class in MyApp.pm
  25. In that case "# Controller error" block will look like:
  26.  
  27. # Controller error
  28. unless ($success) {
  29. my $excaptionPackage = $c->app->exceptionCLassName;
  30. my $e = $ExceptionPackage->new($@);
  31. $c->app->log->error($e);
  32. $app->render_exception($e) if $app->can('render_exception');
  33. return $e;
  34. }
Add Comment
Please, Sign In to add comment