Skip to content

Latest commit

 

History

History
73 lines (53 loc) · 1.88 KB

gas-custom-errors.md

File metadata and controls

73 lines (53 loc) · 1.88 KB
warning layout title
This is a dynamically generated file. Do not edit manually.
default
gas-custom-errors | Solhint

gas-custom-errors

Recommended Badge Category Badge Default Severity Badge warn

The {"extends": "solhint:recommended"} property in a configuration file enables this rule.

Description

Enforces the use of Custom Errors over Require and Revert statements

Options

This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn.

Example Config

{
  "rules": {
    "gas-custom-errors": "warn"
  }
}

Notes

  • This rules applies to Solidity version 0.8.4 and higher

Examples

👍 Examples of correct code for this rule

Use of Custom Errors

revert CustomErrorFunction();

Use of Custom Errors with arguments

revert CustomErrorFunction({ msg: "Insufficient Balance" });

👎 Examples of incorrect code for this rule

Use of require statement

require(userBalance >= availableAmount, "Insufficient Balance");

Use of plain revert statement

revert();

Use of revert statement with message

revert("Insufficient Balance");

Version

This rule was introduced in Solhint 4.5.0

Resources