Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Adding custom errors #136

Open
eugenioclrc opened this issue Aug 31, 2023 · 1 comment
Open

Adding custom errors #136

eugenioclrc opened this issue Aug 31, 2023 · 1 comment

Comments

@eugenioclrc
Copy link
Contributor

Currently there is the REQUIRE that lets you mimic solidity require(condition, "message")

I want to propose a REQUIRE_CUSTOM_ERROR:

#define macro REQUIRE_CUSTOM_ERROR() = takes(2) returns(0) {
    // [condition, customErrorSig]
    do_not_throwErr jumpi
    0x00 mstore
    0x04 0x00 revert

    do_not_throwErr:
    pop
}
@eugenioclrc
Copy link
Contributor Author

Perhaps this is even better, (ERROR_SIGNATURE = PUSH4 SIG):

/// @notice Reverts with a Custom error
#define macro ERR_CUSTOM() = takes (1) returns (0) {
    // ERROR SIGNATURE
    0x00 mstore
    0x04 0x1c revert
}

#define macro REQUIRE_CUSTOM_ERROR(ERROR_SIGNATURE) = takes(2) returns(0) {
    // [condition, customErrorSig]
    do_not_throwErr jumpi
    <ERROR_SIGNATURE>
    ERR_CUSTOM()

    do_not_throwErr:
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant