enum struct. These errors are a special type of enum integer type that are stored on the ledger as Error values containing a u32 code. First, create the Error struct in your smart contract.
Result with their intended return value and the #[contracterror] struct as the error, or just invoke panic_with_error! with the appropriate Error enum value whenever an error condition is reached. By default, most ecosystem standards assume that contract functions do not return a Result, so using panic_with_error! is recommended.
However, both styles behave in the same way. If an error is returned or panic_with_error! is invoked, the transaction will fail. Contracts making cross contract calls have the ability to catch and handle these failures with try_ functions.
ScVal, containing a ScError, containing the integer value of the error as contract error.