Created
August 26, 2022 12:44
-
-
Save ashwinYardi/ce9285be52f1263dd314857108c8c52d to your computer and use it in GitHub Desktop.
Demo solidity contract to demo custom errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.7; | |
contract DemoCustomError { | |
error Unauthorized(); | |
error myCustomError(string message); | |
address public owner = address(0x0); | |
function checkAuthorisation() public view { | |
if(msg.sender != owner) { | |
revert Unauthorized(); | |
} | |
} | |
function testCustomErrorMessage(string calldata message) public pure { | |
revert myCustomError(message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment