From bef9e9d55308d406e0ae51bfa5e84d477d662b6a Mon Sep 17 00:00:00 2001 From: Samer Afach Date: Thu, 31 May 2018 01:49:47 +0200 Subject: [PATCH] Fix a major error in error_code category checking implementations. Errors some times don't throw exceptions due to implementation differences. --- include/jwt/impl/jwt.ipp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/jwt/impl/jwt.ipp b/include/jwt/impl/jwt.ipp index 9ce3ef8..ee1a1de 100644 --- a/include/jwt/impl/jwt.ipp +++ b/include/jwt/impl/jwt.ipp @@ -761,7 +761,8 @@ void jwt_throw_exception(const std::error_code& ec) { const auto& cat = ec.category(); - if (&cat == &theVerificationErrorCategory) + if (&cat == &theVerificationErrorCategory || + std::string(cat.name()) == std::string(theVerificationErrorCategory.name())) { switch (static_cast(ec.value())) { @@ -810,7 +811,8 @@ void jwt_throw_exception(const std::error_code& ec) }; } - if (&cat == &theDecodeErrorCategory) + if (&cat == &theDecodeErrorCategory || + std::string(cat.name()) == std::string(theDecodeErrorCategory.name())) { switch (static_cast(ec.value())) { @@ -836,7 +838,8 @@ void jwt_throw_exception(const std::error_code& ec) assert (0 && "Unknown error code"); } - if (&cat == &theAlgorithmErrCategory) + if (&cat == &theAlgorithmErrCategory || + std::string(cat.name()) == std::string(theAlgorithmErrCategory.name())) { switch (static_cast(ec.value())) {