hd-lang

Tour · 21 of 25

.context turns a low-level failure into a report that says what you were doing

"invalid digit at position 0" is true, but it does not tell anyone what broke. In hd an error type is an enum marked @error: each variant carries its data and its message, and @source keeps the lower-level error it wraps. .context("...") adds what the program was doing on the way up, and report_of prints the whole chain, outermost first. Callers can still match on the variants, because the error is a typed value, not a string. Delete the .context(...) call and Run: each report loses the line that says what failed.

Run: Ctrl+Enter · Pages: Alt+← Alt+→