WeaveDocs
Strand Errors

Usage

Using `strand-errors` — attach structured context, propagate typed errors across crate boundaries, and bridge std::io errors.

Purpose

Shared error hierarchy, serialization, context wrappers, error codes, and IO mapping.

This page follows the real source shape for Strand Errors and explains the workflow a developer is likely to use first.

Developer workflow

Start from the smallest constructor or builder, perform one meaningful operation, inspect the returned state, then add the relevant policy, storage, or network integration. The examples below should be expanded whenever the crate API changes.

Primary types to know

  • SerializedError — libs/strand-errors/src/lib.rs
  • CryptoError — libs/strand-errors/src/lib.rs
  • ErrorCode — libs/strand-errors/src/lib.rs
  • OwnershipError — libs/strand-errors/src/lib.rs
  • ProtocolError — libs/strand-errors/src/lib.rs
  • ReplicationError — libs/strand-errors/src/lib.rs
  • StorageError — libs/strand-errors/src/lib.rs
  • StrandError — libs/strand-errors/src/lib.rs
  • ValidationError — libs/strand-errors/src/lib.rs
  • ErrorContext — libs/strand-errors/src/lib.rs
  • ToIoErrorKind — libs/strand-errors/src/lib.rs

Example shape

use strand::{Strand, StrandConfig};
use strand_errors::StrandError;

#[tokio::main]
async fn main() {
    let cfg = StrandConfig::new(); // no storage path — produces an error on append
    let mut strand = Strand::new(cfg).await.unwrap();

    match strand.append(b"x").await {
        Ok(seq) => println!("appended at {seq}"),
        Err(StrandError::Storage(msg)) => eprintln!("storage error: {msg}"),
        Err(e) => eprintln!("other error: {e}"),
    }
}