Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions are not available in the after_dispatch hook when exception_format is set to json #2048

Closed
evoyy opened this issue Mar 10, 2023 · 2 comments · Fixed by #2065
Closed

Comments

@evoyy
Copy link

evoyy commented Mar 10, 2023

  • Mojolicious version: 9.31
  • Perl version: 5.36.0
  • Operating system: Ubuntu 22.04

Steps to reproduce the behavior

According to the Routing guide, the recommended way to forward exceptions to a web service is in the after_dispatch hook:

# Forward exceptions to a web service
$app->hook(after_dispatch => sub ($c) {
  return unless my $e = $c->stash('exception');
  $c->ua->post('https://example.com/bugs' => form => {exception => $e});
});

https://docs.mojolicious.org/Mojolicious/Guides/Routing#Hooks

However, when the exception_format is set to json, the exception is not available in the stash, so it is not possible to forward exceptions to a web service using the same technique. I'm not sure if this would be considered a bug or just a limitation of using json format exceptions.

@rawleyfowler
Copy link
Contributor

Working on a fix for this.

@evoyy
Copy link
Author

evoyy commented May 9, 2023

Confirmed working, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants