This readme file provides the overview of the error
smart contract, in this I am showing the error handling mechanism in Solidity.
This error
contract having several functions. So, I am explaining all the functions serial wise :
-
requireExample
: This function's access specifier is pure and it is publicly accessible and it usesrequire
statement to validate user inputs. This checks that the given values lies between the range 10 and 100 or not. If the condition is false, then transaction shows the error. -
revertExample
: This function's access specifier is pure and it is publicly accessible and in this function I am demonstrating use ofrevert
by giving an if condition, if condition is true then the revert statement is executed. -
assertExample
: This functions's access specifier is also pure and it's return type is bool. Now, In this I am usingassert
statement. If given condition is true then assertion will be true otherwise it shows an error. -
add
: This function allows owner to add amount in remaining balance by usingrequire
. -
deduct
: This function allows user to deduct or withdraw amount from remaining balance by again usingrequire
.
-
Require
: Used to validate certain conditions before further execution of a function. It takes two parameters as an input. -
Assert
: The assert function, like require, is a convenience function that checks for conditions. If a condition fails, then the function execution is terminated with an error message. -
Revert
: Can be used to flag an error and revert the current call. You can also provide a message containing details about the error, and the message will be passed back to the caller.
- Harshit Kumar