Hi

On 4/30/25 15:33, Larry Garfield wrote:
The only time I've seen anyone use $code is in TYPO3.  Their coding standards 
say that any time you throw an exception, you use the current timestamp 
(determined manually) as a code.  That way there is a globally unique code 
regardless of exception type that can be grepped to find the exact line it came 
from.

To my understanding this would result in effectively identical exceptions having different codes, just because checking the error condition is split across different `if()` statements for readability? That doesn't seem like a good idea - and that's why the RFC uses “cause” as the wording of choice.

[…] just that it's the only time I've seen $code used in the wild...


PDO (for better or worse) also uses the `$code` for the error code returned by the database. Unfortunately it also widens the (untyped) $code from int to string|int, which causes some issues, since folks only expect int, since Exception::__construct() types the `$code` parameter as `int`.

Best regards
Tim Düsterhus

Reply via email to