Skip to content

UNI016: Throwing System.Exception directly

What and why

throw new Exception() directly (use a specific exception type).

Throwing System.Exception forces callers to catch everything.

How to fix: define and throw a domain-specific exception type.

Fix guidance

Throw a domain-specific exception type instead of System.Exception.

Tags

reliability, exceptions

Suppression

Use // unilyze-disable-next-line UNI016 -- reason immediately before the reported line. These detector findings are line-based, so separate overload occurrences can be suppressed independently. For project-wide suppression, use "rules": { "UNI016": "off" }; use a baseline to freeze existing findings while reporting new ones.