Include previous exception in catch and throw

This commit is contained in:
Marc Ypes
2018-11-12 13:47:17 +01:00
parent 34ec35019b
commit 3b983ad0b4
6 changed files with 28 additions and 21 deletions

View File

@@ -505,12 +505,12 @@ abstract class AbstractGrant implements GrantTypeInterface
return bin2hex(random_bytes($length));
// @codeCoverageIgnoreStart
} catch (\TypeError $e) {
throw OAuthServerException::serverError('An unexpected error has occurred');
throw OAuthServerException::serverError('An unexpected error has occurred', $e);
} catch (\Error $e) {
throw OAuthServerException::serverError('An unexpected error has occurred');
throw OAuthServerException::serverError('An unexpected error has occurred', $e);
} catch (\Exception $e) {
// If you get this message, the CSPRNG failed hard.
throw OAuthServerException::serverError('Could not generate a random string');
throw OAuthServerException::serverError('Could not generate a random string', $e);
}
// @codeCoverageIgnoreEnd
}