crates/lint/docs/unused-error.md
Severity: Info
ID: unused-error
Flags a custom error declaration that is never referenced anywhere in the compiled sources.
Reports each error declaration whose symbol is never referenced. Any resolved reference counts
as a use: a revert Err(...) statement (including the qualified revert Lib.Err(...)),
require(cond, Err(...)) (Solidity 0.8.26+), and Err.selector (including through
abi.encodeWithSelector). Uses are collected across the whole compilation unit,
so an error declared in a shared file and reverted elsewhere in the project is not reported.
Errors declared in interfaces and abstract contracts are not reported: they are ABI surface meant for implementers and off-chain consumers, which may live outside the compiled sources.
An unused error is dead code. It suggests a missing revert path or a leftover from a refactor.
error Unauthorized(); // declared but never referenced
error Unauthorized();
function withdraw() external {
if (msg.sender != owner) revert Unauthorized();
}
A selector hardcoded in inline assembly or built with abi.encodeWithSignature("Err(...)") does
not reference the declaration and is not seen as a use.