Repository navigation
host: give each domain of the new APIs its own error type - #1267
Enrique Saurez (esaurez) wants to merge 1 commit into
Conversation
Add ConfigError, LaunchError, TransportError, SnapshotError, RestoreError and ReportError in host::error, one file each in host/error/. Each has a kind from a small, non-exhaustive enum of its own domain, which kind() returns, a message, which it displays, and an optional source, as the crate-wide Error has, without its codes. No API returns them yet: the host's new APIs take them up as they come, while the existing ones keep the crate-wide Error, ErrorKind and ErrorCode. The public API snapshots list the new types. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1504d30d-8f6a-4254-9b3d-b350b73fe01e
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the domain-specific host error additions.
No open issues 🎉
What changed in this PR
This PR implements SL2.1 of #1097 by introducing six domain-specific error types for future host APIs. Existing APIs retain the legacy crate-wide error types and behavior.
Changes:
- Add independent error kinds, display messages, and optional sources for configuration, launch, transport, snapshot, restore, and report errors.
- Add unit tests covering every initial kind, message display, and source handling.
- Document the new module and record its 57 public API additions in both platform snapshots.
| File | Description |
|---|---|
nvx-rs/src/host/mod.rs |
Declares and documents host::error, re-exporting its types. |
nvx-rs/src/host/error/transport/tests.rs |
Tests transport kinds, messages, and sources. |
nvx-rs/src/host/error/transport.rs |
Defines transport errors and their classifications. |
nvx-rs/src/host/error/snapshot/tests.rs |
Tests snapshot kinds, messages, and sources. |
nvx-rs/src/host/error/snapshot.rs |
Defines snapshot errors and their classifications. |
nvx-rs/src/host/error/restore/tests.rs |
Tests restore kinds, messages, and sources. |
nvx-rs/src/host/error/restore.rs |
Defines restore errors and their classifications. |
nvx-rs/src/host/error/report/tests.rs |
Tests report kinds, messages, and sources. |
nvx-rs/src/host/error/report.rs |
Defines report errors and their classifications. |
nvx-rs/src/host/error/launch/tests.rs |
Tests launch kinds, messages, and sources. |
nvx-rs/src/host/error/launch.rs |
Defines launch errors and their classifications. |
nvx-rs/src/host/error/config/tests.rs |
Tests configuration kinds, messages, and sources. |
nvx-rs/src/host/error/config.rs |
Defines configuration errors and their classifications. |
nvx-rs/README.md |
Documents the module and its separation from legacy errors. |
nvx-rs/public-api/windows.txt |
Records the new public error API on Windows. |
nvx-rs/public-api/linux.txt |
Records the same public error API on Linux. |
Review effort: Balanced
|
Closing as not planned: the plan in #1076 changed. |
Part of #1097. Stacked on #1261.
What and why
SL2.1 of #1097: each domain of the host's new APIs gets an error type of its
own, instead of the crate-wide
Errorand its registry of 30 codes.nvx::host::errorholds six types, one file each innvx-rs/src/host/error/:ConfigError,LaunchError,TransportError,SnapshotError,RestoreErrorandReportError.#[non_exhaustive]enum of its own domain,which
kind()returns; a message, which it displays; and an optionalsource, which
with_sourcesets andsource()returns, as the crate-wideErrorbehaves, without its codes. The kinds are independent ofErrorCode:ConfigErrorKindhasInvalidandUnsupported, and theothers name what fails in a launch, a transport, a snapshot, a restore or
a report.
the existing ones keep the crate-wide
Error,ErrorKindandErrorCode,whose taxonomy, registry and tests don't change.
nvx-rs/README.mdgets the module's row and section.Public API
Both snapshots gain the same 57 items: the module, the six types with
new,kindandwith_source, and their kinds' variants. None is removed.Size
298 core lines in 7 counted files, as measured; #1097 estimated 300, in one
folder with one file per type. Each type's file counts 45 to 50 lines, and
host/mod.rs, which declares the module, 14.Tests
No existing test changes, and none is retired: the crate-wide error's
taxonomy and table tests in
nvx-rs/src/error/tests.rsstay as they are.Each new type's
tests.rsaddsan_error_has_the_kind_that_it_was_created_withand
an_error_displays_its_message_and_exposes_its_source.scripts/check_test_changes.pyreports 0 changes and 30 added items.Validation
The gates below ran at the heads that they name, which hold this patch on
an earlier head of SL0.4 or before it:
git range-diffshows the patchunchanged, and SL0.4 changes no Rust input. On this head, the public API
check, the script tests that SL0.4 touches, the README, link and layout
checks,
check_test_changesand the size ran again, and pass.check-nvx-rsfor the crate andthe runtime adapter, 24 of 24, with the
cliandtestingClippy builds.validate-nvx, at 108c0900: all pass butscripts/test_adversarial.py, whose 4test_contained_*_kills_descendantscases fail under the shared virtual environment's Microsoft Store Python
3.13. Under a standard CPython 3.14.9, all 84 of its tests pass, at
83f50d2a, 11 of them skipped as Linux-only. The first run, at 99333456,
before SL0.4, also timed out one loopback test of
scripts/test_microvm_tests.pyat 69 to 96% host CPU, which passed 3 of 3alone, and the environment's timestamp guard saw 157 files change: pip's
own bytecode, which no step of these gates writes. The run at 108c0900,
with that bytecode moved aside and the host's processes watched, changed
none.
directory: a replay of
check-nvx-rs; the OpenVMM vector and CPU profiletests; the shell, Markdown, test layout, kernel configuration and specula
checks; and the 13 steps of
validate-nvxthat need no VM: all pass.