Skip to content

Instantly share code, notes, and snippets.

@ashwinYardi
Created August 26, 2022 12:44
Show Gist options
  • Save ashwinYardi/ce9285be52f1263dd314857108c8c52d to your computer and use it in GitHub Desktop.
Save ashwinYardi/ce9285be52f1263dd314857108c8c52d to your computer and use it in GitHub Desktop.
Demo solidity contract to demo custom errors
// 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