mockforge_test/
error.rs

1//! Error types for MockForge test utilities
2
3use std::io;
4use thiserror::Error;
5
6/// Result type for MockForge test operations
7pub type Result<T> = std::result::Result<T, Error>;
8
9/// Errors that can occur when using MockForge test utilities
10#[derive(Error, Debug)]
11pub enum Error {
12    /// Server failed to start
13    #[error("Failed to start MockForge server: {0}")]
14    ServerStartFailed(String),
15
16    /// Server health check failed
17    #[error("Health check failed: {0}")]
18    HealthCheckFailed(String),
19
20    /// Server health check timed out
21    #[error("Health check timed out after {0}s")]
22    HealthCheckTimeout(u64),
23
24    /// HTTP request error
25    #[error("HTTP request failed: {0}")]
26    HttpError(#[from] reqwest::Error),
27
28    /// IO error
29    #[error("IO error: {0}")]
30    IoError(#[from] io::Error),
31
32    /// Process error
33    #[error("Process error: {0}")]
34    ProcessError(String),
35
36    /// Configuration error
37    #[error("Configuration error: {0}")]
38    ConfigError(String),
39
40    /// Scenario switching error
41    #[error("Failed to switch scenario: {0}")]
42    ScenarioError(String),
43
44    /// Port allocation error
45    #[error("Port {0} is already in use")]
46    PortInUse(u16),
47
48    /// MockForge binary not found
49    #[error("MockForge binary not found. Please ensure it's installed or in PATH")]
50    BinaryNotFound,
51
52    /// JSON parsing error
53    #[error("JSON parsing error: {0}")]
54    JsonError(#[from] serde_json::Error),
55
56    /// YAML parsing error
57    #[error("YAML parsing error: {0}")]
58    YamlError(#[from] serde_yaml::Error),
59
60    /// Workspace error
61    #[error("Workspace error: {0}")]
62    WorkspaceError(String),
63
64    /// Invalid response from server
65    #[error("Invalid response from server: {0}")]
66    InvalidResponse(String),
67}