pub enum BpiError {
Network {
message: String,
},
Http {
status: u16,
},
Parse {
message: String,
},
Api {
code: i32,
message: String,
category: ErrorCategory,
},
Authentication {
message: String,
},
InvalidParameter {
field: &'static str,
message: &'static str,
},
}
Variants§
Network
网络请求失败
Http
HTTP状态码错误
Parse
JSON解析失败
Api
API返回的业务错误
Authentication
验证错误
InvalidParameter
§参数错误
Implementations§
Source§impl BpiError
impl BpiError
pub fn missing_csrf() -> Self
pub fn missing_data() -> Self
pub fn auth_required() -> Self
Source§impl BpiError
生成Error的From实现
impl BpiError
生成Error的From实现
pub fn from_code_message(code: i32, message: String) -> Self
Sourcepub fn from_api_response<T>(resp: BpiResponse<T>) -> Self
pub fn from_api_response<T>(resp: BpiResponse<T>) -> Self
从API响应创建BpiError
Source§impl BpiError
错误创建函数
impl BpiError
错误创建函数
Source§impl BpiError
错误判断
impl BpiError
错误判断
Sourcepub fn requires_login(&self) -> bool
pub fn requires_login(&self) -> bool
判断是否需要用户登录
Sourcepub fn is_permission_error(&self) -> bool
pub fn is_permission_error(&self) -> bool
判断是否为权限问题
Sourcepub fn requires_vip(&self) -> bool
pub fn requires_vip(&self) -> bool
判断是否需要VIP权限
Sourcepub fn is_business_error(&self) -> bool
pub fn is_business_error(&self) -> bool
判断是否为业务逻辑错误
Trait Implementations§
Source§impl Error for BpiError
impl Error for BpiError
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<T> From<BpiResponse<T>> for BpiError
impl<T> From<BpiResponse<T>> for BpiError
Source§fn from(resp: BpiResponse<T>) -> Self
fn from(resp: BpiResponse<T>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for BpiError
impl RefUnwindSafe for BpiError
impl Send for BpiError
impl Sync for BpiError
impl Unpin for BpiError
impl UnwindSafe for BpiError
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> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
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.