v2 Contract SDK
  • Orbs Contract SDK
  • Getting Started
    • About smart contracts
    • Becoming a Go developer
    • Installing Gamma - local blockchain
    • Deploying your first contract
    • The Orbs Starter Kit
    • Downloading the Contract SDK
  • Orbs Contracts
    • Smart contracts
    • Layout of a contract file
    • Data types (Exported Functions)
    • State
    • Address
    • Events
    • Error handling
    • Calling other contracts
    • Calling Ethereum contract
    • API Reference
    • Limitations of Orbs Contracts
    • Creating a new contract
  • Gamma in Depth
    • Starting and stopping the server
    • Test keys and accounts
    • Deploying smart contracts
    • Sending transactions and queries
    • Checking sent transaction status
    • Reading Logs from Contracts
    • Working with multiple environments
    • Upgrading to latest versions
    • Gamma server under the hood
    • Deploying Gamma in the Cloud
      • Amazon Web Services
      • Google Cloud Platform
      • Azure
Powered by GitBook
On this page
  1. Orbs Contracts

Error handling

The execution flow of Orbs contracts does not include error handling, meaning that once an error occurs, code execution stops, the state in the blockchain is not stored, and any changes done up until the error are reverted.

When the contract execution hits an error, the ExecutionResult is set to ERROR_SMART_CONTRACT, and an error message is set in OutputArguments.

Using panic is the simplest way to report an error from within a contract, and in a similar way seen above, the error message is returned as part of the output arguments of the execution.

For example, the code:

func throw() {
    panic("the error message from the code")
}

Will output the following result on execution:

{
  "RequestStatus": "COMPLETED",
  "ExecutionResult": "ERROR_SMART_CONTRACT",
  "OutputArguments": [
    {
      "Type": "string",
      "Value": "the error message from the code"
    }
  ]
}
PreviousEventsNextCalling other contracts

Last updated 5 years ago