Skip to content
Snippets Groups Projects
error_code.hh 997 B
Newer Older
  • Learn to ignore specific revisions
  • #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";
    
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    /**
     * 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
    };
    
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    /**
     * 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