On this page

Error vocabulary๏ƒ

๐ŸŸข Beginner ยท Lesson 06

Failing well on day one - every exception melder raises at you is catchable from the root namespace. No internal paths, ever.

Before you run๏ƒ

Use the Beginner guide for prerequisite concepts. Run from a checkout with Melder installed and Python 3.14 free-threading selected. The collection download includes the level's local helper modules.

Run the saved script๏ƒ

python UX_and_AIX_experiences/01_beginner/06_error_vocabulary.py
py -3.14t UX_and_AIX_experiences/01_beginner/06_error_vocabulary.py

Download this collection ยท Source on GitHub

Public surface๏ƒ

md.SpellbookValidationError, md.MeldExecutionError

Code๏ƒ

 1"""
 2TIER: beginner (06)
 3GOAL: Failing well on day one - every exception melder raises at you is
 4      catchable from the root namespace. No internal paths, ever.
 5SURFACE EXERCISED: md.SpellbookValidationError, md.MeldExecutionError
 6"""
 7import melder as md
 8
 9
10class Registered:
11    pass
12
13
14class NeverRegistered:
15    pass
16
17
18def main() -> None:
19    book = md.Spellbook()
20    book.bind(spell=Registered, existence=md.Existence.unique)
21    conduit = book.conjure()
22
23    try:
24        conduit.meld(spell=NeverRegistered)
25    except KeyError as err:
26        # the documented "not found anywhere" contract is one stable KeyError
27        print("unregistered spell -> KeyError:", err)
28
29    # the full catchable family, importable without knowing ANY internal path
30    family = [
31        md.SpellbookValidationError, md.MeldExecutionError,
32        md.SpellSpaceScopeError, md.HookExecutionError,
33        md.InternalRegistrationError, md.PhaseSchedulerError,
34        md.PhaseExecutionError, md.PhaseTimeoutError, md.DeadReferenceError,
35    ]
36    assert all(issubclass(e, BaseException) for e in family)
37    print("error vocabulary size:", len(family))
38
39
40if __name__ == "__main__":
41    main()

Check the outcome๏ƒ

The script contains its own assertions or demonstrated refusal paths. Run it to evaluate those checks against your installed version. The code above is taken directly from the saved file; no run output is invented here.

More beginner examples ยท Level guide

API contracts๏ƒ