0

Lets say i have this error:

error Main__ContractNotAllowed();

And also i have this modifier which checks this mapping:

mapping (address => bool) private isAllowed;

modifier onlyAllowedContracts() {
    require(isAllowed[msg.sender] == true);
    _;
}

Now i wanna put error inside this modifier which every time this function reverts ,this error shows up. is it possible? or i should do this in another way?

Thank you.

1 Answer 1

3

You can design it like this:

modifier onlyAllowedContracts() {
    if (isAllowed[msg.sender] != true) revert Main__ContractNotAllowed();
    _;
}

1
  • I figured out in this exact way couple minutes after posting this question, But thank you.
    – Alireza
    Commented Jan 24, 2023 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.