mars-protocol · errors
Public declarations and documentation for mars-protocol::errors.
Package: mars-protocol · Workspace version: 0.1.0 · Module: errors
This reference follows declared modules and public syntax, including public implementation methods. Function bodies and constant values are omitted. Feature conditions are retained. Private-module re-exports and trait resolution require the compiler; not every declaration is a root import.
errors::MarsError
Unified error type for MARS protocol operations.
#[derive(Debug, Clone, thiserror::Error)]
pub enum MarsError {
/// A field failed validation.
#[error("validation error on `{field}`: {reason}")]
ValidationError { field: String, reason: String },
/// A referenced entry or resource was not found.
#[error("not found: {0}")]
NotFound(String),
/// Signature verification failed.
#[error("signature error: {0}")]
SignatureError(String),
/// Hash mismatch between computed and expected values.
#[error("hash mismatch on `{field}`: expected {expected}, got {actual}")]
HashMismatch {
field: String,
expected: String,
actual: String,
},
/// Lifecycle state transition is not permitted.
#[error("invalid lifecycle transition from {from} to {to}")]
InvalidLifecycleTransition { from: String, to: String },
/// Machine-readable protocol error with MARS error code.
#[error("[{code}] {message}")]
ProtocolError {
code: MarsErrorCode,
message: String,
},
}Source line: 11.
errors::MarsErrorCode
Machine-readable error codes per MARS Specification Section 12.5.
Each code maps to an HTTP status code and a semantic description.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
pub enum MarsErrorCode {
/// MARS-001 (400): Invalid entry schema.
#[serde(rename = "MARS-001")]
InvalidEntrySchema,
/// MARS-002 (400): Invalid entry signature.
#[serde(rename = "MARS-002")]
InvalidEntrySignature,
/// MARS-003 (400): Invalid publisher DID.
#[serde(rename = "MARS-003")]
InvalidPublisherDid,
/// MARS-004 (400): Invalid lineage chain.
#[serde(rename = "MARS-004")]
InvalidLineageChain,
/// MARS-005 (400): Hash mismatch (itemDataHash ≠ computed hash).
#[serde(rename = "MARS-005")]
HashMismatch,
/// MARS-006 (401): Missing or invalid authentication token.
#[serde(rename = "MARS-006")]
MissingOrInvalidToken,
/// MARS-007 (403): Insufficient permissions for operation.
#[serde(rename = "MARS-007")]
InsufficientPermissions,
/// MARS-008 (404): Entry not found.
#[serde(rename = "MARS-008")]
EntryNotFound,
/// MARS-009 (409): Conflict (version exists, tamper detected, or concurrent update).
#[serde(rename = "MARS-009")]
Conflict,
/// MARS-010 (402): Insufficient bond for entry type.
#[serde(rename = "MARS-010")]
InsufficientBond,
/// MARS-011 (410): Entry has been revoked.
#[serde(rename = "MARS-011")]
EntryRevoked,
/// MARS-012 (422): itemData does not conform to itemSchemaUri.
#[serde(rename = "MARS-012")]
ItemDataSchemaViolation,
/// MARS-013 (429): Rate limit exceeded.
#[serde(rename = "MARS-013")]
RateLimitExceeded,
/// MARS-014 (503): On-chain anchoring temporarily unavailable.
#[serde(rename = "MARS-014")]
AnchoringUnavailable,
/// MARS-015 (504): Weave DHT write timeout.
#[serde(rename = "MARS-015")]
DhtWriteTimeout,
}Source line: 49.
errors::MarsErrorCode::code_string
Returns the MARS-NNN code string.
pub fn code_string(&self) -> &'static str;Source line: 99.
errors::MarsErrorCode::http_status
Returns the corresponding HTTP status code.
pub fn http_status(&self) -> u16;Source line: 120.
errors::MarsErrorCode::description
Returns a human-readable description.
pub fn description(&self) -> &'static str;Source line: 141.
errors::MarsErrorCode::all
Returns all 15 error codes.
pub fn all() -> &'static [Self];Source line: 162.
Source provenance
Source: mars-protocol/src/errors.rs · SHA-256 37dc67f120a1dec75d28f2f11f48f698c4aa20c7f0c71d77106cdfb5e864a770. Package overview.