#[non_exhaustive]pub enum Error {
Show 34 variants
System(String),
InvalidCredential(String),
InvalidGrantType(String),
InvalidAppId(String),
InvalidCode(String),
InvalidParameter(String),
InvalidSecret(String),
ForbiddenIp(String),
CodeBlocked(String),
SecretFrozen(String),
MissingAccessToken(String),
MissingAppId(String),
MissingSecret(String),
MissingCode(String),
RequiredPostMethod(String),
DailyRequestLimitExceeded(String),
RateLimitExceeded(String),
ForbiddenToken(String),
AccountFrozen(String),
ThirdPartyToken(String),
SessionKeyNotExistedOrExpired(String),
InvalidSignatureMethod(String),
InvalidSignature(String),
ConfirmRequired(String),
RequestDeniedOneDay(String),
RequestDeniedOneHour(String),
Unpad(UnpadError),
AesInvalidLength(InvalidLength),
Base64Decode(DecodeError),
Reqwest(Error),
SerdeJson(Error),
InternalServer(String),
Http(Error),
UrlParse(ParseError),
}Expand description
微信小程序 SDK 错误枚举
包含了所有可能遇到的错误类型,包括微信 API 错误、网络错误、加解密错误等。
§错误分类
§微信 API 错误
这些错误对应微信官方文档中的错误码:
InvalidCredential: 凭证无效InvalidCode: 登录 code 无效RateLimitExceeded: API 调用频率限制- 等等…
§第三方库错误
自动转换的第三方库错误:
Reqwest: HTTP 请求错误SerdeJson: JSON 序列化/反序列化错误Base64Decode: Base64 解码错误AesInvalidLength: AES 加解密长度错误
§系统错误
System: 微信系统繁忙InternalServer: 内部服务器错误
§序列化
此枚举使用 thiserror 派生宏,提供了良好的错误消息格式。
每个变体都包含描述性的错误信息。
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
System(String)
微信系统繁忙,请稍候再试
InvalidCredential(String)
获取 access_token 时 AppSecret 错误,或者 access_token 无效
InvalidGrantType(String)
不合法的凭证类型
InvalidAppId(String)
不合法的 AppID,请检查 AppID 的正确性
InvalidCode(String)
登录 code 无效或已过期
InvalidParameter(String)
请求参数错误
InvalidSecret(String)
无效的 appsecret,请检查 appsecret 的正确性
ForbiddenIp(String)
IP 地址不在白名单中
CodeBlocked(String)
高风险等级用户,小程序登录被拦截
SecretFrozen(String)
AppSecret 已被冻结,请登录小程序平台解冻
MissingAccessToken(String)
缺少 access_token 参数
MissingAppId(String)
缺少 appid 参数
MissingSecret(String)
缺少 secret 参数
MissingCode(String)
缺少 code 参数
RequiredPostMethod(String)
需要 POST 请求
DailyRequestLimitExceeded(String)
调用超过天级别频率限制
RateLimitExceeded(String)
API 调用太频繁,请稍候再试
ForbiddenToken(String)
禁止使用 token 接口
AccountFrozen(String)
账号已冻结
ThirdPartyToken(String)
第三方平台 API 需要使用第三方平台专用 token
SessionKeyNotExistedOrExpired(String)
session_key 不存在或已过期
InvalidSignatureMethod(String)
无效的签名方法
InvalidSignature(String)
无效的签名
ConfirmRequired(String)
此次调用需要管理员确认,请耐心等候
RequestDeniedOneDay(String)
该IP调用请求已被公众号管理员拒绝,请24小时后再试
RequestDeniedOneHour(String)
该IP调用请求已被公众号管理员拒绝,请1小时后再试
Unpad(UnpadError)
AES 解密时数据填充错误
AesInvalidLength(InvalidLength)
AES 加解密长度错误
Base64Decode(DecodeError)
Base64 解码错误
Reqwest(Error)
Reqwet 请求错误
SerdeJson(Error)
JSON 序列化/反序列化错误
InternalServer(String)
内部服务器错误
Http(Error)
HTTP 请求错误
UrlParse(ParseError)
Url 解析错误
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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 Error
impl From<DecodeError> for Error
Source§fn from(source: Base64DecodeError) -> Self
fn from(source: Base64DecodeError) -> Self
Converts to this type from the input type.
Source§impl From<Error> for Error
impl From<Error> for Error
Source§fn from(source: ReqwestError) -> Self
fn from(source: ReqwestError) -> Self
Converts to this type from the input type.
Source§impl From<Error> for Error
impl From<Error> for Error
Source§fn from(source: SerdeJsonError) -> Self
fn from(source: SerdeJsonError) -> Self
Converts to this type from the input type.
Source§impl From<InvalidLength> for Error
impl From<InvalidLength> for Error
Source§fn from(source: AesInvalidLength) -> Self
fn from(source: AesInvalidLength) -> Self
Converts to this type from the input type.
Source§impl From<ParseError> for Error
impl From<ParseError> for Error
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Converts to this type from the input type.
Source§impl From<UnpadError> for Error
impl From<UnpadError> for Error
Source§fn from(error: UnpadError) -> Self
fn from(error: UnpadError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
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.