Merge pull request #22 from TheQuantumPhysicist/FixErrorCategoryComparison

Fix a major error in error_code category checking implementations.
This commit is contained in:
Arun Muralidharan 2018-05-31 09:36:24 +05:30 committed by GitHub
commit ea3bcd6223
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -761,7 +761,8 @@ void jwt_throw_exception(const std::error_code& ec)
{ {
const auto& cat = ec.category(); const auto& cat = ec.category();
if (&cat == &theVerificationErrorCategory) if (&cat == &theVerificationErrorCategory ||
std::string(cat.name()) == std::string(theVerificationErrorCategory.name()))
{ {
switch (static_cast<VerificationErrc>(ec.value())) switch (static_cast<VerificationErrc>(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<DecodeErrc>(ec.value())) switch (static_cast<DecodeErrc>(ec.value()))
{ {
@ -836,7 +838,8 @@ void jwt_throw_exception(const std::error_code& ec)
assert (0 && "Unknown error code"); assert (0 && "Unknown error code");
} }
if (&cat == &theAlgorithmErrCategory) if (&cat == &theAlgorithmErrCategory ||
std::string(cat.name()) == std::string(theAlgorithmErrCategory.name()))
{ {
switch (static_cast<AlgorithmErrc>(ec.value())) switch (static_cast<AlgorithmErrc>(ec.value()))
{ {