Skip to main content
When a script can’t be run, or fails while running, the server responds with an error instead of a returnValue:
Most messages end with the line number where the problem was found.

Error types

Lexing and parsing happen before any statement runs, so a LexError or ParseError means no part of the script was executed.

Runtime errors

A RuntimeError stops the script at the statement that caused it. Common causes:
  • A value doesn’t match a variable’s or parameter’s type: Cannot use a int32 value as string in the declaration of 's'.
  • A name isn’t declared, or is declared twice: Unknown variable 'y', Variable 'x' is already declared and cannot be redeclared.
  • Assigning to a const or a contract parameter: Cannot assign to 'limit' because it is a const.
  • An integer overflows its type: int32 overflow: 2147483648.
  • Dividing by zero.
  • A list index is out of bounds or not an integer.
  • An if condition, or an operand of !, && or ||, isn’t a boolean.
  • Reading a property of something that isn’t an object.
  • A resource is unknown, or a resource function is called with missing, unknown or wrongly typed arguments.

Resource failures are not errors

When a resource function fails, for example because a downstream service is unavailable, the script doesn’t stop. The failure is reported to the script in the call’s result, and the script decides what to do. See Handling resource results. Other HTTP errors, such as an unknown contract or a malformed request body, are listed in the HTTP API reference.