pub enum ErrorCode {
InvalidInput,
Unauthenticated,
Forbidden,
NotFound,
Conflict,
FailedPrecondition,
RateLimited,
Internal,
NotImplemented,
Unavailable,
}Expand description
Protocol-agnostic error code that maps to HTTP status, gRPC code, CLI exit code, etc.
Variants§
InvalidInput
400 Bad Request / INVALID_ARGUMENT / exit 1
Unauthenticated
401 Unauthorized / UNAUTHENTICATED / exit 1
Forbidden
403 Forbidden / PERMISSION_DENIED / exit 1
NotFound
404 Not Found / NOT_FOUND / exit 1
Conflict
409 Conflict / ALREADY_EXISTS / exit 1
FailedPrecondition
422 Unprocessable Entity / FAILED_PRECONDITION / exit 1
RateLimited
429 Too Many Requests / RESOURCE_EXHAUSTED / exit 1
Internal
500 Internal Server Error / INTERNAL / exit 1
NotImplemented
501 Not Implemented / UNIMPLEMENTED / exit 1
503 Service Unavailable / UNAVAILABLE / exit 1
Implementations§
Source§impl ErrorCode
impl ErrorCode
Sourcepub fn http_status(&self) -> u16
pub fn http_status(&self) -> u16
Convert to HTTP status code
Sourcepub fn jsonrpc_code(&self) -> i32
pub fn jsonrpc_code(&self) -> i32
Convert to JSON-RPC error code.
Standard codes: -32700 parse error, -32600 invalid request, -32601 method not found, -32602 invalid params, -32603 internal error. Server-defined codes are in the range -32000 to -32099.
Sourcepub fn infer_from_name(name: &str) -> Self
pub fn infer_from_name(name: &str) -> Self
Infer error code from type/variant name (convention-based)