pub enum BpiError {
Network {
message: String,
},
Transport {
source: Error,
},
Http {
status: u16,
},
HttpStatus {
status: u16,
},
Parse {
message: String,
},
Decode {
source: Error,
},
Api {
code: i32,
message: String,
category: ErrorCategory,
},
Authentication {
message: String,
},
Auth {
message: String,
},
InvalidParameter {
field: &'static str,
message: &'static str,
},
MissingData,
UnsupportedResponse {
message: String,
},
}Variants§
Network
网络请求失败
Transport
Transport-level request failure.
Http
HTTP状态码错误
HttpStatus
HTTP status error.
Parse
JSON解析失败
Decode
Response decode failure.
Api
API返回的业务错误
Authentication
验证错误
Auth
Authentication or authorization error.
InvalidParameter
§参数错误
MissingData
API response succeeded but did not include required payload data.
UnsupportedResponse
Response format is not supported by the current parser.
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: ApiEnvelope<T>) -> Self
pub fn from_api_response<T>(resp: ApiEnvelope<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_risk_control(&self) -> bool
pub fn is_risk_control(&self) -> bool
判断是否为风控拦截
Sourcepub fn is_business_error(&self) -> bool
pub fn is_business_error(&self) -> bool
判断是否为业务逻辑错误
Sourcepub fn semantic_error(&self) -> Option<&'static str>
pub fn semantic_error(&self) -> Option<&'static str>
获取可写入合同的稳定语义错误标签
Trait Implementations§
Source§impl Error for BpiError
impl Error for BpiError
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<ApiEnvelope<T>> for BpiError
impl<T> From<ApiEnvelope<T>> for BpiError
Source§fn from(resp: ApiEnvelope<T>) -> Self
fn from(resp: ApiEnvelope<T>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for BpiError
impl !UnwindSafe for BpiError
impl Freeze for BpiError
impl Send for BpiError
impl Sync for BpiError
impl Unpin for BpiError
impl UnsafeUnpin 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
impl<T> ErasedDestructor for Twhere
T: 'static,
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.