elemental_core/runtime/
error.rs1use std::{io, path::PathBuf, process::ExitStatus};
2
3#[derive(Debug, thiserror::Error)]
4#[non_exhaustive]
5pub enum Error {
6 #[error(
7 "Java property probe timed out after {timeout_secs} seconds: {}",
8 executable.display()
9 )]
10 ProbeTimeout {
11 executable: PathBuf,
12 timeout_secs: u64,
13 },
14
15 #[error("run Java property probe failed: {}", executable.display())]
16 ProbeSpawn {
17 executable: PathBuf,
18 #[source]
19 source: io::Error,
20 },
21
22 #[error(
23 "Java property probe exited unsuccessfully with {status}: {}",
24 executable.display()
25 )]
26 ProbeFailed {
27 executable: PathBuf,
28 status: ExitStatus,
29 },
30
31 #[error(
32 "Java property probe returned no recognizable major version: {}",
33 executable.display()
34 )]
35 ProbeMissingVersion { executable: PathBuf },
36
37 #[error("read Java release file failed: {}", path.display())]
38 ReadRelease {
39 path: PathBuf,
40 #[source]
41 source: io::Error,
42 },
43
44 #[error("check Java release file failed: {}", path.display())]
45 CheckRelease {
46 path: PathBuf,
47 #[source]
48 source: io::Error,
49 },
50
51 #[error("Java release file has no recognizable major version: {}", path.display())]
52 ReleaseMissingVersion { path: PathBuf },
53
54 #[error("canonicalize Java runtime root failed: {}", path.display())]
55 CanonicalizeRuntimeRoot {
56 path: PathBuf,
57 #[source]
58 source: io::Error,
59 },
60
61 #[error("determine Java runtime properties failed: {}", path.display())]
62 DetermineRuntimeProperties {
63 path: PathBuf,
64 #[source]
65 source: Box<Error>,
66 },
67
68 #[error(
69 "build Java runtime distribution from {provider} at '{}' failed",
70 path.display()
71 )]
72 BuildDistribution {
73 provider: &'static str,
74 path: PathBuf,
75 #[source]
76 source: Box<Error>,
77 },
78
79 #[error(
80 "can't determine Java major version for explicit runtime distribution: {}",
81 path.display()
82 )]
83 RuntimeVersionUnknown { path: PathBuf },
84
85 #[error("can't find a local Java runtime with major version {major_version}")]
86 RuntimeNotFound { major_version: usize },
87
88 #[error(
89 "explicit runtime distribution has Java major version {actual}, expected {expected}: {}",
90 path.display()
91 )]
92 VersionMismatch {
93 actual: usize,
94 expected: usize,
95 path: PathBuf,
96 },
97
98 #[error("custom runtime path is not a directory: {}", path.display())]
99 CustomRuntimeNotDirectory { path: PathBuf },
100
101 #[error("custom runtime path does not contain a java executable: {}", path.display())]
102 CustomRuntimeMissingJava { path: PathBuf },
103
104 #[error("canonicalize custom runtime path failed: {}", path.display())]
105 CanonicalizeCustomRuntime {
106 path: PathBuf,
107 #[source]
108 source: io::Error,
109 },
110}
111
112pub type Result<T> = std::result::Result<T, Error>;