Newer
Older
#ifndef __VEREIGN_GRPC_ERROR_CODES_HH
#define __VEREIGN_GRPC_ERROR_CODES_HH
#include <cstdint>
#include <string>
namespace vereign::grpc {
static constexpr const char* ClientErrorStatus = "Vereign Client Library Error";
/**
* Error codes returned into the gRPC API response `code` field on various failures.
*
* These are errors that happen inside the Vereign Client Library.
* The errors that happen inside the Vereign Restful API are in the standard HTTP status code range
* below 600.
*/
enum class ErrorCode : uint64_t {
ClientError = 1000,
UnexpectedError = 1001,
DeviceNotRegistered = 1002,
InvalidPinCode = 1003,
InvalidIdentity = 1004
};
/**
* Convert the error code to string.
*
* @param ec The error code.
* @returns the error code integer as string.
*/
inline auto ErrorCodeAsString(ErrorCode ec) -> std::string {
return std::to_string(uint64_t(ec));
}
}
#endif // __VEREIGN_GRPC_ERROR_CODES_HH