Skip to main content

WxPayError

Enum WxPayError 

Source
pub enum WxPayError {
Show 33 variants ConfigError { message: String, }, InvalidPrivateKey(String), InvalidCertificate(String), MissingConfig { field: String, }, SignError(String), SignatureVerificationFailed, InvalidSignatureFormat(String), EncryptionError(String), DecryptionError(String), InvalidKey(String), InvalidCiphertext(String), CertificateDownloadError(String), CertificateParseError(String), CertificateExpired, CertificateVerificationError(String), CertificateNotFound(String), NetworkError(Error), RequestBuildError(String), ResponseParseError(String), Timeout, ApiError { code: String, message: String, }, UnexpectedStatusCode(u16), BusinessError(String), NotifySignatureVerificationFailed, NotifyDecryptionError(String), InvalidNotifyFormat(String), InvalidNotifyType(String), JsonError(Error), UrlEncodeError(String), UrlParseError(ParseError), InternalError(String), UnsupportedOperation(String), InvalidParameter(String),
}
Expand description

微信支付 SDK 错误类型

Variants§

§

ConfigError

配置错误

Fields

§message: String
§

InvalidPrivateKey(String)

无效的私钥

§

InvalidCertificate(String)

无效的证书

§

MissingConfig

缺少必填配置项

Fields

§field: String
§

SignError(String)

签名生成失败

§

SignatureVerificationFailed

签名验证失败

§

InvalidSignatureFormat(String)

无效的签名格式

§

EncryptionError(String)

加密失败

§

DecryptionError(String)

解密失败

§

InvalidKey(String)

无效的密钥

§

InvalidCiphertext(String)

无效的密文格式

§

CertificateDownloadError(String)

证书下载失败

§

CertificateParseError(String)

证书解析失败

§

CertificateExpired

证书已过期

§

CertificateVerificationError(String)

证书验证失败

§

CertificateNotFound(String)

找不到匹配的证书

§

NetworkError(Error)

网络错误

§

RequestBuildError(String)

HTTP 请求构建失败

§

ResponseParseError(String)

HTTP 响应解析失败

§

Timeout

请求超时

§

ApiError

微信支付 API 错误

Fields

§code: String

错误码

§message: String

错误信息

§

UnexpectedStatusCode(u16)

API 返回了意外的状态码

§

BusinessError(String)

业务逻辑错误

§

NotifySignatureVerificationFailed

通知签名验证失败

§

NotifyDecryptionError(String)

通知解密失败

§

InvalidNotifyFormat(String)

无效的通知格式

§

InvalidNotifyType(String)

无效的通知类型

§

JsonError(Error)

JSON 序列化/反序列化错误

§

UrlEncodeError(String)

URL 编码错误

§

UrlParseError(ParseError)

URL 解析错误

§

InternalError(String)

内部错误

§

UnsupportedOperation(String)

不支持的操作

§

InvalidParameter(String)

参数错误

Implementations§

Source§

impl WxPayError

Source

pub fn config(message: impl Into<String>) -> Self

创建配置错误

Source

pub fn missing_config(field: impl Into<String>) -> Self

创建缺少配置项错误

Source

pub fn sign(message: impl Into<String>) -> Self

创建签名错误

Source

pub fn encryption(message: impl Into<String>) -> Self

创建加密错误

Source

pub fn decryption(message: impl Into<String>) -> Self

创建解密错误

Source

pub fn certificate_parse(message: impl Into<String>) -> Self

创建证书错误

Source

pub fn certificate_download(message: impl Into<String>) -> Self

创建证书下载错误

Source

pub fn certificate_verification(message: impl Into<String>) -> Self

创建证书验证错误

Source

pub fn api(code: impl Into<String>, message: impl Into<String>) -> Self

创建 API 错误

Source

pub fn internal(message: impl Into<String>) -> Self

创建内部错误

Source

pub fn invalid_parameter(message: impl Into<String>) -> Self

创建参数错误

Source

pub fn business(message: impl Into<String>) -> Self

创建业务错误

Source

pub fn api_kind(&self) -> Option<WxPayErrorKind>

获取 API 错误分类

Source

pub fn api_code(&self) -> Option<&str>

获取 API 错误码

Source

pub fn alert_level(&self) -> WxPayAlertLevel

告警级别(用于结构化日志告警策略)

Source

pub fn alert_policy(&self) -> &'static str

告警策略键(用于指标/告警策略路由)

Source

pub fn should_retry(&self) -> bool

是否建议重试

Source

pub fn is_network_error(&self) -> bool

判断是否为网络错误

Source

pub fn is_api_error(&self) -> bool

判断是否为 API 错误

Source

pub fn is_auth_error(&self) -> bool

判断是否为鉴权相关错误

Source

pub fn is_signature_error(&self) -> bool

判断是否为签名/验签错误

Source

pub fn is_certificate_error(&self) -> bool

判断是否为证书错误

Trait Implementations§

Source§

impl Debug for WxPayError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for WxPayError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for WxPayError

Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<DecodeError> for WxPayError

从 base64 错误转换

Source§

fn from(err: DecodeError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for WxPayError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for WxPayError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for WxPayError

从 RSA 错误转换

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for WxPayError

从 PKCS 错误转换

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for WxPayError

从 DER 错误转换

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<ParseError> for WxPayError

Source§

fn from(source: ParseError) -> Self

Converts to this type from the input type.
Source§

impl From<ParseError> for WxPayError

从时间解析错误转换

Source§

fn from(err: ParseError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more