pub enum FlareError {
Localized {
code: ErrorCode,
reason: String,
details: Option<String>,
params: Option<HashMap<String, String>>,
timestamp: DateTime<Utc>,
},
System(String),
Io(String),
}Expand description
Flare IM 统一错误类型
Variants§
Implementations§
Source§impl FlareError
impl FlareError
Sourcepub fn system(msg: impl Into<String>) -> FlareError
pub fn system(msg: impl Into<String>) -> FlareError
创建系统错误
Sourcepub fn io(msg: impl Into<String>) -> FlareError
pub fn io(msg: impl Into<String>) -> FlareError
创建 IO 错误
Sourcepub fn connection_failed(reason: impl Into<String>) -> FlareError
pub fn connection_failed(reason: impl Into<String>) -> FlareError
创建连接失败错误
Sourcepub fn connection_timeout(reason: impl Into<String>) -> FlareError
pub fn connection_timeout(reason: impl Into<String>) -> FlareError
创建连接超时错误
Sourcepub fn connection_closed(reason: impl Into<String>) -> FlareError
pub fn connection_closed(reason: impl Into<String>) -> FlareError
创建连接已关闭错误
Sourcepub fn authentication_failed(reason: impl Into<String>) -> FlareError
pub fn authentication_failed(reason: impl Into<String>) -> FlareError
创建认证失败错误
Sourcepub fn authentication_expired(reason: impl Into<String>) -> FlareError
pub fn authentication_expired(reason: impl Into<String>) -> FlareError
创建认证过期错误
Sourcepub fn protocol_error(reason: impl Into<String>) -> FlareError
pub fn protocol_error(reason: impl Into<String>) -> FlareError
创建协议错误
Sourcepub fn message_format_error(reason: impl Into<String>) -> FlareError
pub fn message_format_error(reason: impl Into<String>) -> FlareError
创建消息格式错误
Sourcepub fn message_send_failed(reason: impl Into<String>) -> FlareError
pub fn message_send_failed(reason: impl Into<String>) -> FlareError
创建消息发送失败错误
Sourcepub fn user_not_found(user_id: impl Into<String>) -> FlareError
pub fn user_not_found(user_id: impl Into<String>) -> FlareError
创建用户不存在错误
Sourcepub fn user_offline(user_id: impl Into<String>) -> FlareError
pub fn user_offline(user_id: impl Into<String>) -> FlareError
创建用户离线错误
Sourcepub fn serialization_error(reason: impl Into<String>) -> FlareError
pub fn serialization_error(reason: impl Into<String>) -> FlareError
创建序列化错误
Sourcepub fn deserialization_error(reason: impl Into<String>) -> FlareError
pub fn deserialization_error(reason: impl Into<String>) -> FlareError
创建反序列化错误
Sourcepub fn encoding_error(reason: impl Into<String>) -> FlareError
pub fn encoding_error(reason: impl Into<String>) -> FlareError
创建编码错误
Sourcepub fn general_error(reason: impl Into<String>) -> FlareError
pub fn general_error(reason: impl Into<String>) -> FlareError
创建通用错误
Sourcepub fn timeout(reason: impl Into<String>) -> FlareError
pub fn timeout(reason: impl Into<String>) -> FlareError
创建操作超时错误
Sourcepub fn as_localized(&self) -> Option<LocalizedError>
pub fn as_localized(&self) -> Option<LocalizedError>
获取本地化错误信息(如果有)
Sourcepub fn to_localized(self) -> LocalizedError
pub fn to_localized(self) -> LocalizedError
转换为本地化错误
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
判断是否为可重试的错误
Trait Implementations§
Source§impl Clone for FlareError
impl Clone for FlareError
Source§fn clone(&self) -> FlareError
fn clone(&self) -> FlareError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FlareError
impl Debug for FlareError
Source§impl Display for FlareError
impl Display for FlareError
Source§impl Error for FlareError
impl Error for FlareError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<DecodeError> for FlareError
impl From<DecodeError> for FlareError
Source§fn from(err: DecodeError) -> FlareError
fn from(err: DecodeError) -> FlareError
Converts to this type from the input type.
Source§impl From<EncodeError> for FlareError
impl From<EncodeError> for FlareError
Source§fn from(err: EncodeError) -> FlareError
fn from(err: EncodeError) -> FlareError
Converts to this type from the input type.
Source§impl From<Error> for FlareError
impl From<Error> for FlareError
Source§fn from(err: Error) -> FlareError
fn from(err: Error) -> FlareError
Converts to this type from the input type.
Source§impl From<Error> for FlareError
impl From<Error> for FlareError
Source§fn from(err: Error) -> FlareError
fn from(err: Error) -> FlareError
Converts to this type from the input type.
Source§impl From<Error> for FlareError
impl From<Error> for FlareError
Source§fn from(err: Error) -> FlareError
fn from(err: Error) -> FlareError
Converts to this type from the input type.
Source§impl From<Error> for FlareError
impl From<Error> for FlareError
Source§fn from(err: Error) -> FlareError
fn from(err: Error) -> FlareError
Converts to this type from the input type.
Source§impl From<Error> for FlareError
impl From<Error> for FlareError
Source§fn from(err: Error) -> FlareError
fn from(err: Error) -> FlareError
Converts to this type from the input type.
Source§impl From<FlareError> for HttpApiError
impl From<FlareError> for HttpApiError
Source§fn from(err: FlareError) -> HttpApiError
fn from(err: FlareError) -> HttpApiError
Converts to this type from the input type.
Source§impl<T> From<FlareError> for ApiResponse<T>
从 FlareError 转换为 ApiResponse
impl<T> From<FlareError> for ApiResponse<T>
从 FlareError 转换为 ApiResponse
转换规则:
- HTTP 错误码 (400-599): 保持原样
- 其他错误码: 统一转换为 500 (HttpInternalServerError)
Source§fn from(err: FlareError) -> ApiResponse<T>
fn from(err: FlareError) -> ApiResponse<T>
Converts to this type from the input type.
Source§impl From<LocalizedError> for FlareError
impl From<LocalizedError> for FlareError
Source§fn from(err: LocalizedError) -> FlareError
fn from(err: LocalizedError) -> FlareError
Converts to this type from the input type.
Source§impl From<RedisError> for FlareError
impl From<RedisError> for FlareError
Source§fn from(err: RedisError) -> FlareError
fn from(err: RedisError) -> FlareError
Converts to this type from the input type.
Source§impl From<Status> for FlareError
impl From<Status> for FlareError
Source§fn from(status: Status) -> FlareError
fn from(status: Status) -> FlareError
Converts to this type from the input type.
Source§impl From<TryFromIntError> for FlareError
impl From<TryFromIntError> for FlareError
Source§fn from(err: TryFromIntError) -> FlareError
fn from(err: TryFromIntError) -> FlareError
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for FlareError
impl RefUnwindSafe for FlareError
impl Send for FlareError
impl Sync for FlareError
impl Unpin for FlareError
impl UnsafeUnpin for FlareError
impl UnwindSafe for FlareError
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request