Core Library0.xTopics

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

MoreLess about this notice
Edit this page on GitHub

Errors and exceptions

Needs libtmux for C++ 0.x Install

A command can fail because tmux rejects it, or because the transport stops before returning a reply. Inspect the reported error and delivery state before retrying a mutation: tmux may already have received it.

For lookup failures caused by zero or multiple matches, see Filtering and queries.

A failed command, as a value

Fallible operations return expected<T, CommandFailure>. CommandFailure records the failure kind, delivery status, exit code, and diagnostic.

Is it safe to retry?

Retry a mutation automatically only when you know it was not dispatched, or when repeating it is safe for your operation. A timeout, cancellation, or dropped connection can occur after tmux has acted. These APIs expose delivery information:

DeliveryStatus distinguishes not_started, written, replied, and indeterminate.

auto result = session.new_window({.name = "build"});
if (!result.has_value() && result.error().delivery == libtmux::DeliveryStatus::not_started) {
// safe to retry
}

Treat unknown delivery as potentially executed.

A not_started result means the request did not reach tmux. A written result means the transport accepted the request but no terminal reply arrived.

For subprocess calls that complete normally, inspect the exit status. If a call is interrupted or times out without a delivery state, check tmux’s resulting state before repeating a mutation.

Esc
Search in

Type to search.

Reference previewOpen reference