Skip to content

Instantly share code, notes, and snippets.

@TehilaFavourite
Created July 18, 2023 13:51
Show Gist options
  • Save TehilaFavourite/21928d15d6ce92786af72a35d1572b3c to your computer and use it in GitHub Desktop.
Save TehilaFavourite/21928d15d6ce92786af72a35d1572b3c to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
error CustomError(string message);
contract CustomErrorExample {
uint256 public maxValue = 100;
function setValue(uint256 newValue) public {
// Check if the input exceeds the maximum value allowed
if (newValue > maxValue) {
revert CustomError("Value exceeds the maximum allowed");
}
// Set the new value
maxValue = newValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment