Add error codes for signing error checks

This commit is contained in:
Arun M 2017-11-23 12:27:26 +05:30
parent 2290c8733a
commit 53a281640f
6 changed files with 275 additions and 70 deletions

View file

@ -0,0 +1,48 @@
#ifndef CPP_JWT_ERROR_CODES_IPP
#define CPP_JWT_ERROR_CODES_IPP
namespace jwt {
// Anonymous namespace
namespace {
/**
*/
struct AlgorithmErrCategory: std::error_category
{
const char* name() const noexcept override
{
return "algorithms";
}
std::string message(int ev) const override
{
switch (static_cast<AlgorithmErrc>(ev))
{
case AlgorithmErrc::SigningErr:
return "signing failed";
case AlgorithmErrc::VerificationErr:
return "verification failed";
case AlgorithmErrc::NoneAlgorithmUsed:
return "none algorithm used";
};
assert (0 && "Code not reached");
}
};
// Create global object for the error categories
const AlgorithmErrCategory theAlgorithmErrCategory {};
}
// Create the AlgorithmErrc error code
std::error_code make_error_code(AlgorithmErrc err)
{
return { static_cast<int>(err), theAlgorithmErrCategory };
}
} // END namespace jwt
#endif