lager::Result<T>, an alias for
std::result::Result<T, lager::Error>.
Error is #[non_exhaustive], so a match on it needs a catch-all arm and new
variants will not break your build.
Variants
Variant Reference
Connection(String)
The crate did not reach the box at all. This variant also covers a failed Socket.IO
connect.
Timeout(String)
A client-side deadline expired: the HTTP request, a streaming session’s connect
confirmation, or a wait_for needle that never arrived.
The HTTP deadline covers the whole response, including the body. If a box sends the
headers and then stalls on a JSON body past the deadline, the result is also
Error::Timeout. Before lager-net 0.12, the blocking client reported that case as
Error::Decode.
A hardware wait that expires is not this variant.
wait_for_level timing out on
the box comes back as Error::Box with HTTP 502 and
GPIO 'gpio24' did not reach level 1 within 2.0s, because the box completed the
request and reported the outcome. Error::Timeout means the transport gave up.Box { status: u16, message: String }
The box accepted the request and reported a failure. This is the variant you will see
most, and the message is the box’s own text.
A router net’s “not found” reads
Net 'router1' not found with no role, because
router nets deliberately send no role hint.
The box can also report failure with HTTP 200 and success: false — a cross-role
instrument conflict does this. That is still Error::Box.
UnsupportedByBox { message }
The endpoint exists in the API, but this box is too old to serve it. Where the
version is known, the message names it.
A box answers a route it does not serve in one of three ways. It sends HTTP 501, a JSON
404 with "error": "Not found", or an HTML 405 page. The crate reports all three as this
variant. A route’s own 404, such as an unknown net, stays Error::Box. Before lager-net
0.11, the JSON 404 came back as Error::Box.
erase_range(), halt() and a JTAG connect check the debug service’s features before
they send anything. So an old box fails with this variant before it touches the target.
NotSupportedByBox { feature, details }
The crate has no route for this feature on any box. Since crate 0.8, no net type
returns it: Scope was the last stub. The variant stays, so a match on it still
compiles.
DfuFailed { status, exit_code, stdout, stderr }
Box-side dfu-util ran and exited non-zero (HTTP 502 from POST /usb/dfu). Both
output streams are complete, and the message quotes both. dfu-util reports some
device failures on stdout, and its suffix warnings on stderr.
FlashFailed { error, output }
A debug flash ran but programmed nothing. The box answers HTTP 200 with
programmed: false for this (box 0.51.0 and later). error is the box’s verdict line,
and output is the backend’s output.
ProbeBusy { message }
Another operation, such as a flash or an erase, held the debug probe for longer than
the box waits (HTTP 503 from the debug service). Retry when the other operation is
done.
SafetyRefused { message }
The net is configured with allow_destructive: false, and the debug service refused
a flash or an erase (HTTP 403).
Decode(String)
The crate did not parse the response into the expected shape. The cause is a truncated
body, an unexpected field type, or a missing required field.
AuthRequired { box_host, auth_url, message }
A gated box, and no usable credential.
Config(String)
A client-side problem, detected before anything is sent: LAGER_BOX_HOST unset, an
unparseable host, a firmware path whose type cannot be inferred, an unreadable file.
Stream(String)
A UART or RTT session failed: the device disappeared, or the session closed
unexpectedly. An RTT session also reports here that another session holds its port.
UartInUse { message, held_by }
A UART session cannot start when another session holds the net or its serial device.
To end a session that you no longer need, pass held_by to
lager.release_uart_session() and open again. held_by names the net to release (box
0.49.0 or later). When two nets share one device, that is the other net.
Matching
Skipping a test on an old box
Notes
Errorimplementsstd::error::ErrorandDisplay, so?works intoBox<dyn Error>andanyhow::Errorwithout a conversion.From<serde_json::Error>maps intoError::Decode.- The messages are written to be read by a person in CI output. Print the error rather than only its variant.

