Open klor opened 10 months ago
PW doesn't need to reinvent the wheel and become a PHP debugger when we have an excellent debugging tool created by @adrianbj that's specifically tailored to the PW environment and provides all the things you're requesting and much more.
@klor Any classes, whether custom Page classes, modules, or anything should will behave the same with regards to errors, as they all are handled by PW's error handler. If you want verbose errors you need to have debug mode enabled by setting $config->debug=true;
in your /site/config.php file. When enabled, an error in a custom Page class (or anything else) will output the file name, line number, and error message. When you don't have debug mode enabled, PW intentionally hides any details about the error for security purposes, returning only a 500 response and instead logging the error. Like Toutouwai mentioned above, using TracyDebugger will provide even more detail, which is useful in a local development environment.
Short description of the enhancement
Enhance error handling mechanisms in ProcessWire's custom page classes to degrade gracefully and provide comprehensive, developer-friendly error messages.
Optional: Steps that explain the enhancement
Current vs. suggested behavior
Currently, errors in custom page classes result in a stark Server Error 500 with no helpful output for debugging. The suggested behavior is for ProcessWire to gracefully degrade by catching these errors and providing a useful error message that includes specifics about the nature and location of the error, thereby aiding in a quick resolution.
Code example that currently results in error 500:
Why would the enhancement be useful to users?
Implementing a graceful degradation process for errors in custom page classes would make the development process with ProcessWire much more efficient and less frustrating. Developers would spend less time deciphering the cause of generic server errors and more time on productive development, improving both the developer experience and the stability of applications built with ProcessWire.