rfc:engine_exceptions_for_php7
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:engine_exceptions_for_php7 [2015/02/22 17:41] – nikic | rfc:engine_exceptions_for_php7 [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 2: | Line 2: | ||
* Date: 2014-09-30 | * Date: 2014-09-30 | ||
* Author: Nikita Popov < | * Author: Nikita Popov < | ||
- | * Status: | + | * Status: |
- | * Proposed for: PHP 7 | + | |
===== Introduction ===== | ===== Introduction ===== | ||
Line 212: | Line 211: | ||
* It is discouraged to introduce new errors of type '' | * It is discouraged to introduce new errors of type '' | ||
- | The patch attached to this RFC already converts a large number of fatal and recoverable fatal errors to exceptions. It also converts parse errors to exceptions (there's only one of those). | + | In order to avoid updating many tests the current error messages will be retained if the engine/ |
+ | |||
+ | The patch attached to this RFC already converts a large number of fatal and recoverable fatal errors to exceptions. It also converts parse errors to exceptions. | ||
+ | |||
+ | ==== Hierarchy ==== | ||
+ | |||
+ | There is some concern that by extending '' | ||
+ | |||
+ | < | ||
+ | BaseException (abstract) | ||
+ | +- EngineException | ||
+ | +- ParseException | ||
+ | +- Exception | ||
+ | +- ErrorException | ||
+ | +- RuntimeException | ||
+ | +- ... | ||
+ | +- ... | ||
+ | </ | ||
+ | |||
+ | As such engine/ | ||
+ | |||
+ | Whether such a hierarchy (with a new '' | ||
===== Potential issues ===== | ===== Potential issues ===== | ||
Line 252: | Line 272: | ||
// Handle $exception | // Handle $exception | ||
} | } | ||
- | </ | ||
- | |||
- | ==== catch-all blocks in existing code ==== | ||
- | |||
- | As '' | ||
- | |||
- | ==== Cluttered error messages ==== | ||
- | |||
- | Going back to the code-sample from the introduction, | ||
- | |||
- | < | ||
- | Fatal error: Call to a member function method() on a non-object in / | ||
- | </ | ||
- | |||
- | With this RFC the error changes into an uncaught exception: | ||
- | |||
- | < | ||
- | Fatal error: Uncaught exception ' | ||
- | Stack trace: | ||
- | #0 / | ||
- | #1 {main} | ||
- | thrown in / | ||
- | </ | ||
- | |||
- | The uncaught exception message provides more information, | ||
- | |||
- | I think it would be nice to make those messages a bit cleaner (for all exceptions). The following adjustment is simple to do and seems more readable to me: | ||
- | |||
- | < | ||
- | Fatal error: Uncaught EngineException: | ||
- | Stack trace: | ||
- | #0 / | ||
- | #1 {main} | ||
- | thrown in / | ||
- | </ | ||
- | |||
- | Additional improvement (like removing the '' | ||
- | |||
- | < | ||
- | Uncaught EngineException: | ||
- | Stack trace: | ||
- | #0 / | ||
- | #1 {main} | ||
</ | </ | ||
Line 327: | Line 304: | ||
===== Patch ===== | ===== Patch ===== | ||
- | A preliminary | + | A patch for this RFC is available at https:// |
The patch introduces basic infrastructure for this change, replaces '' | The patch introduces basic infrastructure for this change, replaces '' | ||
- | The patch does not yet contain all necessary test updates and is also not yet thoroughly tested. | + | To simplify porting to exceptions it is possible to throw engine exceptions by passing an additional '' |
+ | |||
+ | < | ||
+ | - zend_error_noreturn(E_ERROR, | ||
+ | + zend_error(E_EXCEPTION | E_ERROR, " | ||
+ | + FREE_UNFETCHED_OP1(); | ||
+ | + HANDLE_EXCEPTION(); | ||
+ | </ | ||
+ | |||
+ | The current | ||
===== Vote ===== | ===== Vote ===== | ||
+ | The primary vote decides if the proposal as outlined in the RFC is accepted and requires a 2/3 majority. | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | |||
+ | The secondary vote decides whether or not a '' | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | |||
+ | Voting started on 2015-02-23 and ends on 2015-03-08. |
rfc/engine_exceptions_for_php7.1424626862.txt.gz · Last modified: 2017/09/22 13:28 (external edit)