On this page

Reading the errors๏ƒ

๐ŸŸข Beginner ยท Lesson 23

The three mistakes everyone makes in hour one, and what melder says back. Learn the error shapes once and debugging is easy.

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/23_reading_the_errors.py
py -3.14t UX_and_AIX_experiences/01_beginner/23_reading_the_errors.py

Download this collection ยท Source on GitHub

Public surface๏ƒ

the beginner error contracts (all run-proven)

Code๏ƒ

 1"""
 2TIER: beginner (23)
 3GOAL: The three mistakes everyone makes in hour one, and what melder
 4      says back. Learn the error shapes once and debugging is easy.
 5SURFACE EXERCISED: the beginner error contracts (all run-proven)
 6"""
 7import melder as md
 8
 9
10class Thing:
11    pass
12
13
14def main() -> None:
15    book = md.Spellbook()
16
17    try:
18        book.bind(spell=Thing)  # forgot existence
19    except TypeError:
20        print("1. forgot existence -> TypeError at bind (fail fast)")
21
22    book.bind(spell=Thing, existence="unique")
23    try:
24        book.bind(spell=Thing, existence="many")  # bound it twice
25    except Exception as err:
26        print("2. same class twice ->", type(err).__name__, "at bind")
27
28    conduit = book.conjure()
29    try:
30        conduit.meld(spellframe="nowhere", binding_name="nothing")
31    except KeyError:
32        print("3. unknown address -> KeyError at meld (one stable contract)")
33
34
35if __name__ == "__main__":
36    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