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) -> ErrorCode
pub fn infer_from_name(name: &str) -> ErrorCode
Infer error code from type/variant name (convention-based)
Trait Implementations§
impl Copy for ErrorCode
impl Eq for ErrorCode
impl StructuralPartialEq for ErrorCode
Auto Trait Implementations§
impl Freeze for ErrorCode
impl RefUnwindSafe for ErrorCode
impl Send for ErrorCode
impl Sync for ErrorCode
impl Unpin for ErrorCode
impl UnsafeUnpin for ErrorCode
impl UnwindSafe for ErrorCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.