Skip to main content

avoid-throw

effort: 3m
pro+

Warns when the throw expression is used.

Use this rule if you prefer to avoid throwing exceptions or errors and instead rely on the result pattern.

Example

❌ Bad:

void fn() {
// LINT: Avoid throw expressions. Try rewriting the code without it.
throw 1;
}

✅ Good:

Result fn() {
return Result(error: true);
}

Additional Resources