Curriculum Errors Panics vs errors
Panics vs errors
Errors are for conditions the caller should be expected to handle (bad input, out of memory, missing file). Panics are for conditions that indicate a programmer bug — invariants that must hold but didn't. @panic(msg) aborts the program with a message; unreachable is a no-message hint to the compiler that a code path can't be entered (in debug builds, hitting one panics with reached unreachable; in release builds it's UB). The discipline: errors for expected failures, panics for impossible-by-design conditions.
9 ready
01
pick one TypeScript reaches for throw new Error(...) for both
02
pick oneNow flip the scenario: the function maintains an INVARIANT
03
pick oneSometimes you genuinely DO want to abort with a specific
04
fill blanksFill the missing single-word marker used to mark a switch
05
fill blanks Fill the missing builtin name (without the @). Takes a
06
type one line Type the missing Zig line — the else arm of a switch that
07
type one lineType the missing Zig line — a guard that bypasses panic when
08
write a programWrite a complete Zig program that demonstrates the
09
write a program Write a complete Zig program using unreachable to mark a