WeaveDocs
Strand Errors

Internals

Internals of `strand-errors` — shared error enums, error code mapping, IO bridges, and serialisation rules.

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 std::io;
use strand_errors::{StrandError, ToIoErrorKind};

fn main() {
    // Every error variant the crate emits. Pattern-match on these names —
    // the discriminator is stable across releases.
    let samples = vec![
        StrandError::Storage("disk full".into()),
        StrandError::Signature("bad signature".into()),
        StrandError::InvalidBlock("seq out of range".into()),
        StrandError::Policy("policy denied".into()),
        StrandError::PolicyDenied,
        StrandError::Io(io::Error::new(io::ErrorKind::PermissionDenied, "ro fs")),
    ];

    for err in &samples {
        // ToIoErrorKind maps a StrandError to the closest std::io::ErrorKind,
        // useful when a caller wants to surface a single uniform error type.
        let kind = err.to_io_error_kind();
        eprintln!("variant={} io_kind={:?}", err, kind);
    }
}