Chapter 8: Exceptions, Events, and Logging
Writing contracts is the fundamental purpose of Solidity. However, writing a contract demands sound error and exception handling skills. Errors and exceptions are the norms in programming, and Solidity provides ample infrastructure for managing both. Writing robust contracts with proper error and exception management is one of the requirements for any functional smart contract. Events are another important construct in Solidity. For all the topics that we've discussed so far, we've seen a caller that invokes functions in contracts; however, we have not discussed any mechanism through which a contract notifies its caller and others about changes in its state and otherwise. This is where events come in. Events are a part of event-driven programs where, based on changes within a program, they proactively notify their caller about the changes. The caller is free to use this information or ignore it. Finally, both exceptions and events...