Error handling

Errors are often inadvertently introduced while writing contracts, so writing robust contracts is a good practice and should be followed. Errors are a fact of life in the programming world and writing error-free contracts is a desired skill. Errors can occur at design time or runtime. Solidity is compiled into bytecode and there are design-level checks for any syntax errors at design time while compiling. Runtime errors, however, are more difficult to catch and generally occur while executing contracts. It is important to test the contract for possible runtime errors, but it is more important to write defensive and robust contracts that take care of both design time and runtime errors.

Examples of runtime errors are out-of-gas ...

Get Solidity Programming Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.