Core LibrarystableAPI Reference

Choose documentation 3

stable

Current version

stable
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

function libtmux stable

handle_option_error

Raise exception if error in option command found.

Source and package
Qualified name
libtmux.options.handle_option_error
Module
libtmux.options
Package
libtmux
Source
src/libtmux/options.py
handle_option_error (error: str) → type[exc.OptionError]

Description#

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.OptionError . So to catch any option error, use except exc.OptionError.

Examples#

>>> result = server.cmd(
... 'set-option',
... 'unknown-option-name',
... )
>>> bool(isinstance(result.stderr, list) and len(result.stderr))
True
>>> import pytest
>>> from libtmux import exc
>>> with pytest.raises(exc.OptionError):
... handle_option_error(result.stderr[0])
Parameters
  • error (str) # – Error response from subprocess call.

Raises
Esc

Type to search.

Reference preview Open reference