The errors example demonstrates how to define your own error types.
Error Enums
Errors are a special type of enum integer type that are stored on ledger asError values containing a u32 code.
ScVal, containing a ScError, containing the integer value of the error as contract error.