Comptime Validation and @compileError
Fail the build with clear messages.
Catch Mistakes Before Run Time
Zig lets you reject bad usage while the code compiles. The built-in @compileError stops the build with a message you write. 🛑
Fail with a Clear Message
@compileError takes a comptime string and aborts compilation, printing exactly that text so the caller knows what went wrong.
@compileError("this type is not supported");All lessons in this course
- Reflecting Fields with @typeInfo
- Building Types with @Type
- Comptime Validation and @compileError
- Generating Code with comptime