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

Template::Exception when forwarding #1707

Open
andrewsolomon opened this issue Feb 14, 2024 · 3 comments
Open

Template::Exception when forwarding #1707

andrewsolomon opened this issue Feb 14, 2024 · 3 comments
Labels

Comments

@andrewsolomon
Copy link
Contributor

andrewsolomon commented Feb 14, 2024

Sorry, I couldn't work out whether the bug is in Dancer2 or Template Toolkit. Any idea how to test Template Toolkit independently?

Context

Template-Toolkit-3.101
Dancer2-1.1.0
Perl v5.36.0

Code to replicate the issue

#!/usr/bin/perl

use Dancer2;
set template => 'template_toolkit';

get '/foo'  => sub {
  return forward '/bar';
};

get '/bar' => sub {
  return 'Hello, World!';
};

dance;

To demonstrate the bug

curl http://localhost:3000/foo

and this is what appears in the logs:

>> Dancer2 v1.1.0 server 19422 listening on http://0.0.0.0:3000
[main:19422] debug @2024-02-14 20:04:23> bless( ['file','404.tt: not found',undef], 'Template::Exception' ) in /usr/local/share/perl/5.36.0/Dancer2/Core/Error.pm l. 73

To dodge the bug

Just comment out this line:

set template => 'template_toolkit';
@cromedome
Copy link
Contributor

I get this error when I try to curl http://localhost:3000/, but when I hit /foo, I get exactly what's expected.

That error is telling you that it's trying to use TT to render a 404 page, but there's no template available to satisfy that, and so TT throws an exception.

FYI, if you are running that test case directly from the command line, you won't have https available.

Let me know if this solves things for you!

@andrewsolomon
Copy link
Contributor Author

FYI, if you are running that test case directly from the command line, you won't have https available.

Sorry Jason, that was a typo on my part :-) fixed.

Now, I realise that my expectations are based on old documentation:

https://metacpan.org/release/SUKRIA/Dancer2-0.10/view/lib/Dancer2/Manual.pod#forward

Where's the updated documentation on forward?

@cromedome
Copy link
Contributor

Updated docs are here: https://metacpan.org/dist/Dancer2/view/lib/Dancer2/Manual/Keywords.pod#forward

Implementation details have changed since then. That's very, very old now ;-)

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

No branches or pull requests

2 participants