typeover
curriculum

Curriculum Errors & packaging errors.Is and errors.As exercise 3 · mcq

errors.Is and errors.As

Pick the IDIOMATIC Go declaration of a SENTINEL ERROR — a package-scope value callers compare against with errors.Is. These are how stdlib packages signal specific failure modes (e.g., io.EOF, sql.ErrNoRows, os.ErrNotExist).

TypeScript reference
Pick the idiomatic Go translation

About this theme

Inspecting errors without breaking the wrap chain. errors.Is(err, target) walks the wrap chain looking for a match against a sentinel. errors.As(err, &target) walks looking for a type match, populating target if found. This is the modern, type-safe replacement for instanceof checks on errors.