#2294 - Switch to 100% exceptions
| Identifier | #2294 |
|---|---|
| Issue type | Feature request or suggestion |
| Title | Switch to 100% exceptions |
| Status | Closed (rejected) |
| Tags |
Risk: Major rearchitecting (custom) |
| Handling member | Chris Graham |
| Addon | core |
| Description | Use PHP's set_exception_handler to set a default exception handler, then make warn_exit calls etc into throw calls etc. For most exit's in the code, we should instead be throwing an exception.
Standard PHP errors can be turned into exceptions: http://php.net/manual/en/function.set-error-handler.php#112881 We can update the Code Book to (possibly simplify) the part about error handling. |
| Steps to reproduce | |
| Funded? | No |
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".


Comments
Purists would want us to use exceptions, there's no question about it.
However, from a security and integrity point of view, there's a lot to say about quickly dying out rather than juggling the execution path around. Juggling would create more complex code (more likely to have a security hole), provide extra attack vectors after a threat is established, and increase DOS risks.
So I think our current situation is the best one - we support a toggle to change exit's into throws. This allows code to benefit from exception management if it needs it (e.g. something like the main_include_module block which simulates a request) - while protecting the rest of the system.