mando-lib-macro

OUTDATED (2026-07-10) — this crate does not exist on develop

Verified: no mando-lib-macro in the origin/develop tree and git grep ErrorCode origin/develop is empty. The ErrorCode derive exists only in .worktrees/ experiments (poc-error-extractor, BE-2023, and inside mando-flow-step-derive in the BE-1595/BE-3482 worktrees). On develop, error.kind/error.code fields are extracted at runtime by the mando_core::error! macro from the error’s Debug repr — no derive. The parent poc/CLAUDE.md is stale on this too. Do not confuse with mando-flow-step-derive on develop, which derives ParamEnum/ParamMeta (flow-step params), not ErrorCode. See Mando AGENTS.md Master Guide. Content below kept as a record of the worktree experiments’ design.

Procedural macro crate for the Mando workspace. Provides the #[derive(ErrorCode)] macro used throughout mando-lib.

#[derive(ErrorCode)]

Auto-generates error code tracking for enum variants. Maps each variant to a static string identifier for structured error reporting and observability.

Usage

use mando_lib_macro::ErrorCode;
use thiserror::Error;
 
#[derive(Error, ErrorCode)]
pub enum DataPointError {
    #[error("path fragment '{0}' must contain...")]
    InvalidPathFragmentFormat(usize, String),
 
    #[error("data point not found: {0}")]
    NotFound(String),
}

Generated Output

impl ErrorCode for DataPointError {
    fn error_code(&self) -> &'static str {
        match self {
            Self::InvalidPathFragmentFormat(..) =>
                "crate::datapoint::DataPointError::InvalidPathFragmentFormat",
            Self::NotFound(..) =>
                "crate::datapoint::DataPointError::NotFound",
        }
    }
}

Each variant maps to a fully qualified path string, making error codes stable, unique, and grep-friendly across the codebase.

Dependencies

CratePurpose
synRust syntax parsing
quoteCode generation
proc-macro2Token stream manipulation
proc-macro-crate 3.4.0Resolves renamed crate imports

Notes

  • proc-macro-crate handles cases where mando-lib is imported under a different name
  • The macro is a proc-macro crate (lib type with proc-macro = true)
  • Used alongside thiserror for Display + std::error::Error implementations