Curriculum Errors & packaging errors.Is and errors.As exercise 5 · fill-word
errors.Is and errors.As
Type the errors package function for TYPE extraction (find
an error of a specific type in a wrap chain and bind it to a
variable). Two letters, capitalised.
TypeScript reference
Fill the blanks →
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.