pub enum AptosError {
Show 28 variants
Http(Error),
Json(Error),
Bcs(String),
Url(ParseError),
Hex(FromHexError),
InvalidAddress(String),
InvalidPublicKey(String),
InvalidPrivateKey(String),
InvalidSignature(String),
SignatureVerificationFailed,
InvalidTypeTag(String),
Transaction(String),
SimulationFailed(String),
SubmissionFailed(String),
ExecutionFailed {
vm_status: String,
},
TransactionTimeout {
hash: String,
timeout_secs: u64,
},
Api {
status_code: u16,
message: String,
error_code: Option<String>,
vm_error_code: Option<u64>,
},
RateLimited {
retry_after_secs: Option<u64>,
},
NotFound(String),
AccountNotFound(String),
InvalidMnemonic(String),
InvalidJwt(String),
KeyDerivation(String),
InsufficientSignatures {
required: usize,
provided: usize,
},
FeatureNotEnabled(String),
Config(String),
Internal(String),
Other(Error),
}Expand description
The main error type for the Aptos SDK.
This enum covers all possible error conditions that can occur when interacting with the Aptos blockchain through this SDK.
Variants§
Http(Error)
Error occurred during HTTP communication
Json(Error)
Error occurred during JSON serialization/deserialization
Bcs(String)
Error occurred during BCS serialization/deserialization
Url(ParseError)
Error occurred during URL parsing
Hex(FromHexError)
Error occurred during hex encoding/decoding
InvalidAddress(String)
Invalid account address
InvalidPublicKey(String)
Invalid public key
InvalidPrivateKey(String)
Invalid private key
InvalidSignature(String)
Invalid signature
SignatureVerificationFailed
Signature verification failed
InvalidTypeTag(String)
Invalid type tag format
Transaction(String)
Transaction building error
SimulationFailed(String)
Transaction simulation failed
SubmissionFailed(String)
Transaction submission failed
ExecutionFailed
Transaction execution failed on chain
TransactionTimeout
Transaction timed out waiting for confirmation
Fields
Api
API returned an error response
Fields
RateLimited
Rate limited by the API
NotFound(String)
Resource not found
AccountNotFound(String)
Account not found
InvalidMnemonic(String)
Invalid mnemonic phrase
InvalidJwt(String)
Invalid JWT
KeyDerivation(String)
Key derivation error
InsufficientSignatures
Insufficient signatures for multi-signature operation
FeatureNotEnabled(String)
Feature not enabled
Config(String)
Configuration error
Internal(String)
Internal SDK error (should not happen)
Other(Error)
Any other error
Implementations§
Source§impl AptosError
impl AptosError
Sourcepub fn transaction<S: Into<String>>(msg: S) -> Self
pub fn transaction<S: Into<String>>(msg: S) -> Self
Creates a new transaction error
Sourcepub fn api(status_code: u16, message: impl Into<String>) -> Self
pub fn api(status_code: u16, message: impl Into<String>) -> Self
Creates a new API error from response details
Sourcepub fn api_with_details(
status_code: u16,
message: impl Into<String>,
error_code: Option<String>,
vm_error_code: Option<u64>,
) -> Self
pub fn api_with_details( status_code: u16, message: impl Into<String>, error_code: Option<String>, vm_error_code: Option<u64>, ) -> Self
Creates a new API error with additional details
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Returns true if this is a “not found” error
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Returns true if this is a timeout error
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if this is a transient error that might succeed on retry
Sourcepub fn sanitized_message(&self) -> String
pub fn sanitized_message(&self) -> String
Returns a sanitized version of the error message safe for logging.
This method:
- Removes control characters that could corrupt logs
- Truncates very long messages to prevent log flooding
- Redacts patterns that might indicate sensitive information
§Example
use aptos_sdk::AptosError;
let err = AptosError::api(500, "Internal server error with details...");
let safe_msg = err.sanitized_message();
// safe_msg is guaranteed to be safe for loggingSourcepub fn user_message(&self) -> &'static str
pub fn user_message(&self) -> &'static str
Returns the error message suitable for display to end users.
This is a more conservative sanitization that provides less detail but is safer for user-facing error messages.
Trait Implementations§
Source§impl Debug for AptosError
impl Debug for AptosError
Source§impl Display for AptosError
impl Display for AptosError
Source§impl Error for AptosError
impl Error for AptosError
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
Source§impl From<Error> for AptosError
impl From<Error> for AptosError
Source§impl From<Error> for AptosError
impl From<Error> for AptosError
Source§impl From<Error> for AptosError
impl From<Error> for AptosError
Source§impl From<FromHexError> for AptosError
impl From<FromHexError> for AptosError
Source§fn from(source: FromHexError) -> Self
fn from(source: FromHexError) -> Self
Source§impl From<ParseError> for AptosError
impl From<ParseError> for AptosError
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Auto Trait Implementations§
impl Freeze for AptosError
impl !RefUnwindSafe for AptosError
impl Send for AptosError
impl Sync for AptosError
impl Unpin for AptosError
impl !UnwindSafe for AptosError
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
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.