Curriculum Errors Error sets exercise 1 · mcq
Error sets
TypeScript reaches for a class hierarchy (class NotFoundError
extends Error) or a string-tag union ({ kind: "not-found" })
to enumerate possible errors. Zig has dedicated syntax — an
error{...} set bound to a const. Pick the right Zig
translation.
About this theme
An error set is a finite enumeration of named errors — declared as error{ Empty, BadDigit, ... }. Different APIs declare their own sets; the compiler tracks which errors a function can return as part of the type. error{} is the bottom set (no errors); the inferred set anyerror is the top (matches anything). A function returning ErrSet!T means: either T (success) or one of ErrSet's variants (failure). Composition is via the || operator — ErrA || ErrB makes a set covering both.