Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 1011 Bytes

Error Handling.md

File metadata and controls

26 lines (18 loc) · 1011 Bytes

Error Handling:

  1. assert(bool condition): causes a Panic error and thus state change reversion if the condition is not met - to be used for internal errors.

  2. require(bool condition): reverts if the condition is not met - to be used for errors in inputs or external components.

  3. require(bool condition, string memory message): reverts if the condition is not met - to be used for errors in inputs or external components. Also provides an error message.

  4. revert(): abort execution and revert state changes

  5. revert(string memory reason): abort execution and revert state changes, providing an explanatory string


Slide Screenshot

078.jpg


Slide Deck

  • assert(bool condition) -> Panic/revert
  • require(bool condition [, string memory message]) -> Error, revert
  • assert() vs require()

References