more error detail

This commit is contained in:
Sergio Álvarez 2023-08-16 11:34:21 +02:00
parent 2a5eac7450
commit 0ddde4bc27
No known key found for this signature in database
GPG Key ID: 622780889DFDBDA5
1 changed files with 4 additions and 1 deletions

View File

@ -18,7 +18,10 @@ class PregResponse
public readonly ?string $returnValue,
) {
if (preg_last_error() !== PREG_NO_ERROR) {
throw new Exception('preg_last_error() = '. preg_last_error_msg());
$error = error_get_last();
$detail = preg_last_error() === PREG_INTERNAL_ERROR && !is_null($error) ? (': ' . $error['message']) : '';
throw new Exception('preg_last_error() = ' . preg_last_error_msg() . $detail);
}
}
}