typeover
rust curriculum

Curriculum Errors, crates & tests Custom error enums exercise 2 · mcq

Custom error enums

A parse failure should keep the offending input so the error message can quote it. Pick the variant shape.

TypeScript reference
Pick the idiomatic Go translation

About this theme

Small Rust programs often use an enum for domain errors. This theme teaches error variants, carrying context, Display, and using From so ? can convert lower-level errors. Planned exercises: 1. choose an error enum. 2. recognise context-carrying variants. 3. choose From for conversion. 4. fill an Err(MyError::...). 5. fill a Display arm. 6. write a domain error enum. 7. write a conversion with From. 8. translate TS custom error classes. 9. fix an error propagation type mismatch.