victauri_test/error.rs
1/// Errors that can occur when interacting with the Victauri MCP server from tests.
2#[derive(Debug, thiserror::Error)]
3#[non_exhaustive]
4pub enum TestError {
5 /// Failed to connect to the Victauri MCP server at the expected port.
6 #[error("connection failed ({host}:{port}): {reason}")]
7 Connection {
8 /// Host that was targeted (typically `"127.0.0.1"`).
9 host: String,
10 /// Port that was targeted.
11 port: u16,
12 /// Human-readable explanation of what went wrong.
13 reason: String,
14 },
15
16 /// An HTTP-level error occurred during an MCP request.
17 #[error("MCP request failed: {0}")]
18 Request(#[from] reqwest::Error),
19
20 /// The MCP server returned a JSON-RPC error response.
21 #[error("MCP returned error: {message}")]
22 Mcp {
23 /// JSON-RPC error code.
24 code: i64,
25 /// Human-readable error message from the server.
26 message: String,
27 },
28
29 /// A tool call returned `isError: true` in its result.
30 #[error("tool call failed: {0}")]
31 ToolError(String),
32
33 /// A test assertion evaluated to false.
34 #[error("assertion failed: {0}")]
35 Assertion(String),
36
37 /// A `wait_for` condition did not become true within the allowed time.
38 #[error("timeout: {0}")]
39 Timeout(String),
40
41 /// An element matching the given criteria was not found in the DOM snapshot.
42 #[error("element not found: {0}")]
43 ElementNotFound(String),
44
45 /// A visual regression was detected — screenshot differs from baseline.
46 #[error("visual regression: {0}")]
47 VisualRegression(String),
48
49 /// A catch-all for errors that don't fit other variants (IO, encoding, etc.).
50 #[error("{0}")]
51 Other(String),
52}