-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Errors support in require
#14442
Comments
can i take this issue please? |
I fully support this issue because it increases clarity and expressiveness of the language. It matches "guards" that other languages have. And a great programming pattern is to put all your guards at the top of a function. Recognizing that this issue is now labeled as "must have" I have added at to the documentation at #14539 |
Please lets have it. |
this could be a great implementation for |
Bumping this -- we really need this feature! The readability using custom error types is really bad - requiring branching statements for every check really clutters up the code. So we're still using It would be so awesome to be able to use |
Abstract
Since Gas-efficient Custom Errors were added in
solidity 0.8.4
, therequire
statement has become mostly unused. Theif (!condition) revert CustomError()
pattern sometimes looks branchy and makes requirement understanding somewhat harder.I found a workaround, however, it consumes some more Gas compared to ordinary Custom Errors usage.
Motivation
I propose implementing Custom Errors support for the
require
statement, providing Custom Error as the second parameter instead of an error message.Specification
There are several opportunities:
revert
burningBackwards Compatibility
As Solidity allows function overloading, the creation of
require(bool, error, or other suitable type)
should not break backward compatibility.The text was updated successfully, but these errors were encountered: