> ## Documentation Index
> Fetch the complete documentation index at: https://requestscript.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

> The kinds of errors a script can produce and how they're reported.

When a script can't be run, or fails while running, the server responds with an error instead of a `returnValue`:

```json theme={null}
{
  "error": {
    "type": "RuntimeError",
    "message": "Unknown variable 'totl' (line 4)"
  }
}
```

Most messages end with the line number where the problem was found.

## Error types

| Type | HTTP status | When it happens |
| - | - | - |
| `LexError` | `400` | The source contains something that isn't valid RequestScript text, such as an unknown character (`%`), an unterminated string or an unsupported escape. |
| `ParseError` | `400` | The source is well-formed text but not a valid script, such as a missing declaration, an unknown type, a duplicate object key or parameter name, or empty parameter parentheses. |
| `ParameterError` | `400` | A contract was invoked with a missing, unknown or wrongly typed parameter. |
| `RuntimeError` | `422` | Something went wrong while the script was running. |

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](/resources/results).

Other HTTP errors, such as an unknown contract or a malformed request body, are listed in the [HTTP API reference](/reference/http-api#errors).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.