---
name: "catch"
type: command
status: ok
groups: ["Program Flow"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/catch
revid: 369419
updated: 2024-09-03T18:48:49Z
---

# catch

*Command · Program Flow · Arma 3 v0.50 · introduced in Armed Assault v1.00*

## Description

Processes code when an exception is thrown in a [try](../commands/try.md) block. The exception caught can be found in the *_exception* variable.

## Syntax

```sqf
tryBlock catch code
```

**Parameters:**

- `tryBlock`: Exception Type
- `code`: [Code](../topics/Code.md)

**Returns:** [Anything](../topics/Anything.md)

## Examples

### Example 1

```sqf
try { throw "invalid argument" } catch {hint str _exception};
```

### Example 2

```sqf
123 try { if (_this != 123) throw "invalid argument" } catch { hint str _exception };
```

### Example 3

The correct usage of shorthand alt syntax:

```sqf
try {
    if (a > b) throw "Error: some error"; // OK
    // the command argument is static
} catch {
    hint str _exception;
};

try {
    _someFunc = {
        // ...
    };
    if (a > b) throw (call _someFunc); // NOT OK
    // the command argument is dynamic
    // _someFunc is called first to get the value regardless of (a > b) outcome
} catch {
    hint str _exception;
};

try {
    _someFunc = {
        // ...
    };
    if (a > b) then { throw (call _someFunc) }; /// OK
    // the command argument is dynamic
    // _someFunc is only called when (a > b) is true
} catch {
    hint str _exception;
};
```

## See also

Exception handling · [try](../commands/try.md) · [throw](../commands/throw.md)

<sub>Source: [BI Community Wiki — catch](https://community.bistudio.com/wiki/catch) (revision 369419).</sub>
