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

Need more info for parsing error report #50

Closed
hax opened this issue Aug 9, 2016 · 5 comments
Closed

Need more info for parsing error report #50

hax opened this issue Aug 9, 2016 · 5 comments
Milestone

Comments

@hax
Copy link

hax commented Aug 9, 2016

I just got many errors like:

( ! ) Fatal error: Uncaught exception 'ErrorException' with message 'Unexpected value: link']}'' in .../htdocs/vendor/pug-php/pug/src/Jade/Compiler.php on line 285

Such error report is not very helpful. I guess it come from some syntax error in my pug source, but current error report give no clue.

@kylekatarnls
Copy link
Member

With a try-catch, you can get the trace:

$pug = new \Pug\Pug();
try {
  $pug->render('your-template');
} catch (\Exception $e) {
  echo '<pre>' . $e->getTraceAsString() . '</pre>';
}

And you should see what method of Compiler is called and where in the generated PHP code.

It should be just before link']} in your template code. If you see some blocks with this string, you can copy them here for analyse.

@kylekatarnls kylekatarnls added this to the 2.3 milestone Aug 9, 2016
@kylekatarnls
Copy link
Member

We could pass to Compiler methods some parsing infos (template file, template line of the original parsed code) when some "debug" option would be true.

@kylekatarnls
Copy link
Member

I found a way to inject more informations (pug node type, tag name when it's a tag, file line and file name when it's rendered from a pug file) on the fly in the exceptions thrown. It weel be implemented in the next release with no need to set any option since thoses errors occurs during compilation and not during rendering.

@kylekatarnls kylekatarnls modified the milestones: 2.2, 2.3 Aug 9, 2016
kylekatarnls added a commit that referenced this issue Aug 9, 2016
* #50 More debug infos
* Enable isInline on every nodes
@kylekatarnls
Copy link
Member

With the new version 2.2.1, you should have information about, the tag, file and line where errors happen.

@kylekatarnls
Copy link
Member

pug-php 3 comes with the new error handling system of https://github.com/phug-php/phug and now provides the line and offset from the Pug source file.

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

No branches or pull requests

2 participants