#[non_exhaustive]pub enum Error {
Config(&'static str),
Param(&'static str),
Notify {
message: String,
},
VerifyFailed,
Api {
endpoint: Endpoint,
code: i32,
message: String,
},
Transport {
kind: TransportErrorKind,
message: String,
},
Http {
status: u16,
body: String,
},
InvalidResponse {
endpoint: Endpoint,
message: String,
},
ResponseTooLarge {
limit: usize,
},
}Expand description
EPay SDK error.
Error text generated by the built-in client never includes a request URL.
Response previews are bounded and have key / sign values masked.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Config(&'static str)
Invalid client or protocol configuration.
Param(&'static str)
Invalid outbound request parameter.
Notify
A notification was malformed, unauthenticated by metadata, or
structurally invalid. Signature mismatches use Error::VerifyFailed.
VerifyFailed
MD5 signature verification failed.
Api
The gateway answered with a non-success code.
Fields
Transport
The HTTP transport failed before a response status was available.
Fields
kind: TransportErrorKindFailure classification.
Http
The gateway returned a non-2xx status.
InvalidResponse
The gateway reported success but the payload is unusable.
Fields
ResponseTooLarge
The response body exceeded the configured limit.
Implementations§
Source§impl Error
impl Error
Sourcepub fn endpoint(&self) -> Option<Endpoint>
pub fn endpoint(&self) -> Option<Endpoint>
Gateway endpoint involved, for Error::Api and
Error::InvalidResponse.
Sourcepub fn transport_kind(&self) -> Option<TransportErrorKind>
pub fn transport_kind(&self) -> Option<TransportErrorKind>
Transport failure classification, if this is a transport error.
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Whether the failure was a transport timeout.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether the request never reached (or never received an answer from) the gateway’s application layer, so repeating it is safe for read-only endpoints: transport timeouts / connection failures and HTTP 502/503/504.
crate::RetryPolicy consults this. Business errors
(Error::Api) and malformed responses are never retryable.
Sourcepub fn transport(kind: TransportErrorKind, message: impl Display) -> Self
pub fn transport(kind: TransportErrorKind, message: impl Display) -> Self
Build a transport error with a redacted message.
Custom crate::Transport implementations should use this rather
than formatting a URL-bearing error into the message.
Sourcepub fn http(status: u16, body: &[u8]) -> Self
pub fn http(status: u16, body: &[u8]) -> Self
Build an Error::Http for a non-2xx response, keeping a bounded,
redacted preview of body. Custom crate::Transports should use
this instead of embedding the raw body.
Source§impl Error
Well-known configuration and parameter errors.
impl Error
Well-known configuration and parameter errors.
Sourcepub const INVALID_PID: Self
pub const INVALID_PID: Self
PID must be greater than zero.
Sourcepub const INVALID_KEY: Self
pub const INVALID_KEY: Self
Merchant key must not be empty.
Sourcepub const INVALID_API_URL: Self
pub const INVALID_API_URL: Self
API base URL is malformed or carries credentials, query or fragment.
Sourcepub const INSECURE_API_URL: Self
pub const INSECURE_API_URL: Self
API base URL uses plain HTTP without explicit opt-in.
Sourcepub const INVALID_NOTIFY_URL: Self
pub const INVALID_NOTIFY_URL: Self
notify_url is not an absolute HTTP(S) URL.
Sourcepub const INVALID_RETURN_URL: Self
pub const INVALID_RETURN_URL: Self
return_url is not an absolute HTTP(S) URL.
Sourcepub const INSECURE_NOTIFY_URL: Self
pub const INSECURE_NOTIFY_URL: Self
notify_url uses plain HTTP without explicit opt-in.
Sourcepub const INSECURE_RETURN_URL: Self
pub const INSECURE_RETURN_URL: Self
return_url uses plain HTTP without explicit opt-in.
Sourcepub const MISSING_OUT_TRADE_NO: Self
pub const MISSING_OUT_TRADE_NO: Self
out_trade_no is empty.
Sourcepub const INVALID_OUT_TRADE_NO: Self
pub const INVALID_OUT_TRADE_NO: Self
out_trade_no violates the accepted charset or length.
Sourcepub const MISSING_NOTIFY_URL: Self
pub const MISSING_NOTIFY_URL: Self
Neither the request nor the configuration provides a notify_url.
Sourcepub const MISSING_NAME: Self
pub const MISSING_NAME: Self
Product name is blank.
Sourcepub const NAME_TOO_LONG: Self
pub const NAME_TOO_LONG: Self
Product name exceeds crate::limits::MAX_NAME_BYTES.
Sourcepub const NAME_HAS_CONTROL_CHARS: Self
pub const NAME_HAS_CONTROL_CHARS: Self
Product name contains control characters.
Sourcepub const SITENAME_HAS_CONTROL_CHARS: Self
pub const SITENAME_HAS_CONTROL_CHARS: Self
sitename contains control characters.
Sourcepub const PARAM_TOO_LONG: Self
pub const PARAM_TOO_LONG: Self
param exceeds crate::limits::MAX_PARAM_BYTES.
Sourcepub const SITENAME_TOO_LONG: Self
pub const SITENAME_TOO_LONG: Self
sitename exceeds crate::limits::MAX_SITENAME_BYTES.
Sourcepub const CALLBACK_URL_TOO_LONG: Self
pub const CALLBACK_URL_TOO_LONG: Self
A callback URL exceeds crate::limits::MAX_CALLBACK_URL_BYTES.
Sourcepub const REQUEST_TOO_LARGE: Self
pub const REQUEST_TOO_LARGE: Self
The signed request exceeds crate::limits::MAX_REQUEST_BYTES.
Sourcepub const INVALID_PAY_TYPE: Self
pub const INVALID_PAY_TYPE: Self
Payment type is blank or not a short [A-Za-z0-9_-] identifier.
Sourcepub const INVALID_DEVICE: Self
pub const INVALID_DEVICE: Self
device is blank or not a short [A-Za-z0-9_-] identifier.
Sourcepub const INVALID_MONEY: Self
pub const INVALID_MONEY: Self
Amount is not positive or not parseable.
Sourcepub const INVALID_MONEY_PRECISION: Self
pub const INVALID_MONEY_PRECISION: Self
Amount carries meaningful precision beyond two decimal places.
Sourcepub const MONEY_OUT_OF_RANGE: Self
pub const MONEY_OUT_OF_RANGE: Self
Amount does not fit the i64 fen range.
Sourcepub const MISSING_TRADE_NO: Self
pub const MISSING_TRADE_NO: Self
Exactly one of trade_no / out_trade_no must be given.
Sourcepub const INVALID_TRADE_NO: Self
pub const INVALID_TRADE_NO: Self
trade_no is not a non-blank ASCII identifier.
Sourcepub const MISSING_CLIENT_IP: Self
pub const MISSING_CLIENT_IP: Self
clientip is required by mapi.php.
Sourcepub const INVALID_CLIENT_IP: Self
pub const INVALID_CLIENT_IP: Self
clientip is not a valid IP address.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()