test_manager_lib/
error.rs1use fidl_fuchsia_test_manager::LaunchError;
6use fuchsia_component_test::error::Error as RealmBuilderError;
7use log::warn;
8use thiserror::Error;
9use {fidl_fuchsia_component as fcomponent, fidl_fuchsia_debugger as fdbg};
10
11#[derive(Debug, Error)]
13pub enum TestManagerError {
14 #[error("Error sending response: {0:?}")]
15 Response(#[source] fidl::Error),
16
17 #[error("Error serving test manager protocol: {0:?}")]
18 Stream(#[source] fidl::Error),
19
20 #[error("Cannot convert to request stream: {0:?}")]
21 IntoStream(#[source] fidl::Error),
22}
23
24#[derive(Debug, Error)]
25pub enum LaunchTestError {
26 #[error("Failed to initialize test realm: {0:?}")]
27 InitializeTestRealm(#[source] RealmBuilderError),
28
29 #[error("Failed to create test realm: {0:?}")]
30 CreateTestRealm(#[source] RealmBuilderError),
31
32 #[error("Failed to create test: {0:?}")]
33 CreateTest(fcomponent::Error),
34
35 #[error("Failed to create test: {0:?}")]
36 CreateTestFidl(fidl::Error),
37
38 #[error("Failed to connect to embedded ArchiveAccessor: {0:?}")]
39 ConnectToArchiveAccessor(#[source] anyhow::Error),
40
41 #[error("Failed to connect to embedded LogSettings: {0:?}")]
42 ConnectToLogSettings(#[source] anyhow::Error),
43
44 #[error("Failed to set log interest with the embedded LogSettings: {0:?}")]
45 SetLogInterest(#[source] anyhow::Error),
46
47 #[error("Failed to connect to TestSuite: {0:?}")]
48 ConnectToTestSuite(#[source] anyhow::Error),
49
50 #[error("Failed to connect to StorageAdmin: {0:?}")]
51 ConnectToStorageAdmin(#[source] anyhow::Error),
52
53 #[error("Cannot open exposed directory: {0:?}")]
54 OpenExposedDir(#[source] anyhow::Error),
55
56 #[error("Failed to stream logs from embedded Archivist: {0:?}")]
57 StreamIsolatedLogs(anyhow::Error),
58
59 #[error("Failed to resolve test: {0:?}")]
60 ResolveTest(#[source] anyhow::Error),
61
62 #[error("Failed to read manifest: {0}")]
63 ManifestIo(mem_util::DataError),
64
65 #[error("Resolver returned invalid manifest data")]
66 InvalidResolverData,
67
68 #[error("Invalid manifest: {0:?}")]
69 InvalidManifest(#[source] anyhow::Error),
70
71 #[error("Failed validating test realm: {0:?}")]
72 ValidateTestRealm(#[source] anyhow::Error),
73}
74
75#[derive(Debug, Error)]
76pub enum DebugAgentError {
77 #[error("Failed to connect to DebugAgent: {0:?}")]
78 ConnectToLauncher(#[source] anyhow::Error),
79
80 #[error("Launcher::Launch (for DebugAgent) failed with local error: {0:?}")]
81 LaunchLocal(#[source] fidl::Error),
82
83 #[error("Launcher::Launch (for DebugAgent) produced error response: {0:?}")]
84 LaunchResponse(i32),
85
86 #[error("DebugAgent::AttachTo failed with local error: {0:?}")]
87 AttachToTestsLocal(#[source] fidl::Error),
88
89 #[error("DebugAgent::AttachTo produced error response: {0:?}")]
90 AttachToTestsResponse(fdbg::FilterError),
91}
92
93#[derive(Debug, Error)]
94pub enum FacetError {
95 #[error("Facet '{0}' defined but is null")]
96 NullFacet(&'static str),
97
98 #[error("Invalid facet: {0}, value: {1:?}, allowed value(s): {2}")]
99 InvalidFacetValue(&'static str, String, String),
100}
101
102impl From<FacetError> for LaunchTestError {
103 fn from(e: FacetError) -> Self {
104 Self::InvalidManifest(e.into())
105 }
106}
107
108impl From<LaunchTestError> for LaunchError {
109 fn from(e: LaunchTestError) -> Self {
110 warn!("Error launching test: {:?}", e);
114 match e {
115 LaunchTestError::InitializeTestRealm(_)
116 | LaunchTestError::ValidateTestRealm(_)
117 | LaunchTestError::ConnectToArchiveAccessor(_)
118 | LaunchTestError::ConnectToLogSettings(_)
119 | LaunchTestError::SetLogInterest(_)
120 | LaunchTestError::CreateTestFidl(_)
121 | LaunchTestError::CreateTest(_)
122 | LaunchTestError::StreamIsolatedLogs(_)
123 | LaunchTestError::OpenExposedDir(_)
124 | LaunchTestError::ConnectToStorageAdmin(_) => Self::InternalError,
125 LaunchTestError::InvalidResolverData
126 | LaunchTestError::InvalidManifest(_)
127 | LaunchTestError::ManifestIo(_) => Self::InvalidManifest,
128 LaunchTestError::CreateTestRealm(_) | LaunchTestError::ResolveTest(_) => {
129 Self::InstanceCannotResolve
130 }
131 LaunchTestError::ConnectToTestSuite(_) => Self::FailedToConnectToTestSuite,
132 }
133 }
134}