godot_testability_runtime/
error.rs

1//! Error types for the testability framework.
2
3use thiserror::Error;
4
5/// Result type for test operations.
6pub type TestResult<T> = Result<T, TestError>;
7
8/// Errors that can occur during embedded testing.
9#[derive(Error, Debug)]
10pub enum TestError {
11    /// Runtime initialization failed.
12    #[error("Failed to initialize Godot runtime: {0}")]
13    RuntimeInitialization(String),
14
15    /// Runtime is not available or not running.
16    #[error("Godot runtime is not available")]
17    RuntimeNotAvailable,
18
19    /// Assertion failed during test.
20    #[error("Assertion failed: {0}")]
21    AssertionFailed(String),
22
23    /// Generic test failure with custom message.
24    #[error("Test failed: {0}")]
25    TestFailure(String),
26
27    /// Multiple tests failed.
28    #[error("Tests failed: {0}")]
29    TestsFailed(String),
30
31    /// Runtime error.
32    #[error("Runtime error: {0}")]
33    RuntimeError(String),
34
35    /// I/O error during test operations.
36    #[error("I/O error: {0}")]
37    Io(#[from] std::io::Error),
38}
39
40impl TestError {
41    /// Create a new assertion failed error.
42    pub fn assertion(message: impl Into<String>) -> Self {
43        Self::AssertionFailed(message.into())
44    }
45
46    /// Create a new test failure error.
47    pub fn failure(message: impl Into<String>) -> Self {
48        Self::TestFailure(message.into())
49    }
50}