Open
Description
Currently, solidity doesn't allow defining errors with the following names Panic
and Error
(note: name, not signature).
There are use cases where reverting with this error would be useful.
One example is in library fixed point implementation. When adding two fixed point numbers overflows, then it's useful to revert with Panic(0x11)
to be consistent with how the compiler would revert in such cases. (List of error codes, or Docs)
Possible solutions
- @chriseth suggested allowing something like
import Panic from std.errors
. - Allow defining errors with signature
Panic(uint)
andError(string)
. - Use inline assembly to mimic the error: no need for the compiler to do anything
- Use a collision hack. Find
<name>(uint)
with the same hash asPanic(uint)
and similarly forError(string)
.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Consider to Promote