Masm error constants

From 0xMiden/protocol · View interactive version

Masm error constants is an AI agent skill from the GitHub repository 0xMiden/protocol. Use when adding or editing MASM `assert*` / `panic` instructions — give every assertion a descriptive named error code.

How to use this skill

Skill file

MASM Error Constants

Rule

Every MASM assertion must carry a descriptive error code:

assert.err=ERR_NOTE_NOT_FOUND
assert_eqw.err=ERR_COMMITMENT_MISMATCH

The error constant must:

Why

A bare assert traps with a generic message that tells the debugger nothing about which check failed; a descriptive ERR_ constant ties each trap site to a specific failure mode. Distinct constants per condition also let tests pin the expected error (see assert-specific-error-in-tests).

Examples

# Good
const ERR_NOTE_NOT_FOUND = "note not found"
const ERR_COMMITMENT_MISMATCH = "stored commitment does not match recomputed value"

proc verify_note
    # ...
    assert.err=ERR_NOTE_NOT_FOUND
    # ...
    assert_eqw.err=ERR_COMMITMENT_MISMATCH
end

# Bad: bare assertion
proc verify_note
    assert
end

# Bad: shared generic constant for unrelated cases
const ERR_INVALID = "invalid"
assert.err=ERR_INVALID   # used in 6 places, each meaning something different
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.