pub enum MovementError {
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 Movement SDK.
This enum covers all possible error conditions that can occur when interacting with the Movement blockchain through this SDK.
§Security: Logging Errors
WARNING: The Display implementation on this type may include sensitive
information (e.g., partial key material, JWT tokens, or mnemonic phrases) in
its output. When logging errors, always use sanitized_message()
instead of to_string() or Display:
// WRONG - may leak sensitive data:
log::error!("Failed: {}", err);
// CORRECT - redacts sensitive patterns:
log::error!("Failed: {}", err.sanitized_message());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 MovementError
impl MovementError
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 movement_sdk::MovementError;
let err = MovementError::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 MovementError
impl Debug for MovementError
Source§impl Display for MovementError
impl Display for MovementError
Source§impl Error for MovementError
impl Error for MovementError
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()
Source§impl From<Error> for MovementError
impl From<Error> for MovementError
Source§impl From<Error> for MovementError
impl From<Error> for MovementError
Source§impl From<Error> for MovementError
impl From<Error> for MovementError
Source§impl From<FromHexError> for MovementError
impl From<FromHexError> for MovementError
Source§impl From<ParseError> for MovementError
impl From<ParseError> for MovementError
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Auto Trait Implementations§
impl Freeze for MovementError
impl !RefUnwindSafe for MovementError
impl Send for MovementError
impl Sync for MovementError
impl Unpin for MovementError
impl UnsafeUnpin for MovementError
impl !UnwindSafe for MovementError
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.