Closed dadajuice closed 7 years ago
The current version 2 (it will no longer be true for the next soon coming), pug does not globally catch errors and exceptions, it means you should mute it like any other exceptions/errors in PHP:
Errors:
error_reporting(0);
It can also be done in a pug template:
- error_reporting(0);
For exception, you can use set_exception_handler
Depending on your PHP version, certain fatal errors cannot be caught.
In the next version, pug will have its own error handler and the debug option will exist.
If you get more trouble, please specify the error and the PHP/Pug code?
Thank a lot for your prompt reply! I have an error/exception handler so I'll see what I can do :) I don't have a specific error its just because with XDebug when there's an error it HUGE since it dump the source / stack. I'd like to see the error, but without the source.
Thanks again! You can close this issue since it will have the debug option in the next version :)
Just to be sure you use the recommended approach:
In development version, you should have all the data that can help you to debug, that's why XDebug is verbose, it's for debugging. And so we try for the next version to provide a clean stack trace (with the pug file line/offset source) and helpfull information. We assume it's a development setting so display file paths should be safe.
In production (the website the final users can see), you should display as few information as possible, like "server error" and nothing more, and you should save all available data in an error log file (then for example send a mail to someone). So the user has any information about your file system but you can inspect it later with all data you need.
Yup my things are all setup like that :P Its just that when I have a Pug error in development, lets say about an undefined variable that I haven't sent to my view, it displays a super big error which include the source and complete stack. Thanks again for your help and time!
It may sound like a really stupid question, but how do you disable the debugging errors? I tried the options listed on the PugJs site but it doesn't seems to be less verbose or disable anything.
Thanks!