Closed belisoful closed 1 year ago
The error templates need to be updated for Error Codes but that is another revision.
I actually agree with you on the hackiness. I wasn't expecting this to be accepted as is.
Your parameter overriding is similar to the Throwable for $previous chaining of exceptions. I love it. I'll patch it up.
It does reverse the Exception parameters for message and code, but its an acceptable quirk (for now).
FYI, I'm updating the PHPDoc for this change, so it's taking a few moments more than usual.
Also. this is the code that fits:
public function __construct($errorCode, $errorMessage = null, ...$args)
{
if(!is_int($errorCode)) {
//assume old code
if ($errorMessage !== null || !empty($args)) {
array_unshift($args, $errorMessage);
}
$errorMessage = $errorCode;
$errorCode = 0;
}
because there may not be a second parameter in the old style, which is fine.
OK. Ready for review.
Keep in mind that the error template might need updating with the %%ErrorCode%% token.
By appending
"=NN"
to the errorMessageCode the integer error Code can be set.This also adds the TNetworkException and TSocketException.