vertigo_cli/commons/
error_codes.rs1use std::fmt::{self, Display};
2
3#[derive(Clone, Copy, Debug)]
5#[repr(i32)]
6pub enum ErrorCode {
7 CantOpenWorkspace = 1,
8 CantParseWorkspace = 2,
9 CantFindCdylibMember = 3,
10 PackageNameNotFound = 4,
11 BuildFailed = 5,
12 BuildPrerequisitesFailed = 6,
13 WatcherError = 7,
14 CantAddWatchDir = 8,
15 OtherProcessAlreadyRunning = 9,
16 CantReadWasmRunFromStatics = 10,
17 CantReadStaticFile = 11,
18 CantWriteOrRemoveFile = 12,
19 CantSpawnChildProcess = 13,
20 CouldntWaitForChildProcess = 14,
21 WatchPipeBroken = 16,
22
23 NewProjectDirNotEmpty = 17,
24 NewProjectCantCreateDir = 18,
25 NewProjectCantUnpackStub = 19,
26 NewProjectCantCreateCargoToml = 20,
27 NewProjectCantWriteToCargoToml = 21,
28
29 ServeCantFindHttpBasePath = 22,
30 ServeCantReadIndexFile = 23,
31 ServeCantOpenPort = 24,
32 ServeWasmReadFailed = 25,
33 ServeWasmCompileFailed = 26,
34 ServeWasmInstanceFailed = 27,
35}
36
37impl Display for ErrorCode {
38 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40 write!(f, "{self:?} (exit code {})", *self as i32)
41 }
42}
43
44impl std::error::Error for ErrorCode {}