pub enum ZtkError {
Network(Error),
Api {
code: i32,
message: String,
sub_code: Option<String>,
sub_msg: Option<String>,
},
Parse(Error),
Validation(String),
UrlEncode(String),
}Expand description
SDK 错误类型
包含所有可能的错误情况:
- 网络请求错误
- API 业务错误
- JSON 解析错误
- 参数验证错误
- URL 编码错误
Variants§
Network(Error)
网络请求错误
当 HTTP 请求失败时返回此错误
Api
API 业务错误
当 API 返回业务错误时返回此错误
Fields
Parse(Error)
JSON 解析错误
当 JSON 反序列化失败时返回此错误
Validation(String)
参数验证错误
当请求参数验证失败时返回此错误
UrlEncode(String)
URL 编码错误
当 URL 编码失败时返回此错误
Implementations§
Source§impl ZtkError
impl ZtkError
Sourcepub fn api_with_sub(
code: i32,
message: impl Into<String>,
sub_code: Option<String>,
sub_msg: Option<String>,
) -> Self
pub fn api_with_sub( code: i32, message: impl Into<String>, sub_code: Option<String>, sub_msg: Option<String>, ) -> Self
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Sourcepub fn url_encode(message: impl Into<String>) -> Self
pub fn url_encode(message: impl Into<String>) -> Self
Trait Implementations§
Source§impl Error for ZtkError
impl Error for ZtkError
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()
Auto Trait Implementations§
impl Freeze for ZtkError
impl !RefUnwindSafe for ZtkError
impl Send for ZtkError
impl Sync for ZtkError
impl Unpin for ZtkError
impl !UnwindSafe for ZtkError
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> 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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.