# libtmux.options.handle_option_error

- **Module:** libtmux.options
- **Package:** libtmux
- **Language:** Python
- **Kind:** function
- **Source:** https://github.com/tmux-python/libtmux/blob/38e368c11117fb4aeb2f082d552cd4f210eae06a/src/libtmux/options.py#L120
- **Page:** https://libtmux.org/en/py/stable/reference/libtmux-options-handle_option_error/

```
libtmux.options.handle_option_error(
    error: str,
) -> type[exc.OptionError]
```

Raise exception if error in option command found.

In tmux 3.0, show-option and show-window-option return invalid option instead of
unknown option. See https://github.com/tmux/tmux/blob/3.0/cmd-show-options.c.

In tmux >2.4, there are 3 different types of option errors:

- unknown option
- invalid option
- ambiguous option

In tmux <2.4, unknown option was the only option.

All errors raised will have the base error of :exc:`exc.OptionError`. So to
catch any option error, use ``except exc.OptionError``.

## Examples

```python
>>> result = server.cmd(
...     'set-option',
...     'unknown-option-name',
... )
```

```python
>>> bool(isinstance(result.stderr, list) and len(result.stderr))
True
```

```python
>>> import pytest
>>> from libtmux import exc
```

```python
>>> with pytest.raises(exc.OptionError):
...     handle_option_error(result.stderr[0])
```

## Parameters

- `error` (`str`): Error response from subprocess call.

## Raises

- [`exc.OptionError`](/en/py/stable/reference/libtmux-exc-optionerror/)
- [`exc.UnknownOption`](/en/py/stable/reference/libtmux-exc-unknownoption/)
- [`exc.InvalidOption`](/en/py/stable/reference/libtmux-exc-invalidoption/)
- [`exc.AmbiguousOption`](/en/py/stable/reference/libtmux-exc-ambiguousoption/)
