0Pricing
Zig Academy · Lesson

Inferred Error Sets

Let Zig collect your errors for you.

Listing Errors Is Tedious

Naming every error a function might return can be a chore, especially when it calls other fallible functions. Zig can infer the set.

Leave the Set Off

Write just !T with nothing before the bang. Zig studies the function body and figures out every error it can produce.

fn parse(s: []const u8) !u32 {
    // ...
}

All lessons in this course

  1. Error Sets and the !T Union
  2. Returning Errors from Functions
  3. Propagate Failures with try
  4. Inferred Error Sets
← Back to Zig Academy