1#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, serde::Serialize)]
2#[serde(transparent)]
3pub struct ErrorCode {
4 code: &'static str,
5}
6
7impl std::fmt::Display for ErrorCode {
8 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9 f.write_str(self.code)
10 }
11}
12
13#[derive(Debug, serde::Serialize, serde::Deserialize)]
14#[serde(transparent)]
15pub struct OwnedErrorCode {
16 code: String,
17}
18
19impl std::fmt::Display for OwnedErrorCode {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 f.write_str(&self.code)
22 }
23}
24
25impl ErrorCode {
26 pub fn into_owned(self) -> OwnedErrorCode {
27 OwnedErrorCode {
28 code: self.code.to_string(),
29 }
30 }
31
32 pub const COMMAND_TIMEOUT: ErrorCode = ErrorCode {
33 code: "command-timeout",
34 };
35 pub const COMMAND_ERROR: ErrorCode = ErrorCode {
36 code: "command-error",
37 };
38 pub const COMMAND_FAILURE: ErrorCode = ErrorCode {
39 code: "command-failure",
40 };
41 pub const OLD_REPO_ERROR: ErrorCode = ErrorCode {
42 code: "old-repo-error",
43 };
44 pub const NOT_FOUND: ErrorCode = ErrorCode { code: "not-found" };
45 pub const FILE_IO_ERROR: ErrorCode = ErrorCode {
46 code: "file-io-error",
47 };
48 pub const FILE_EXISTS: ErrorCode = ErrorCode {
49 code: "file-exists",
50 };
51 pub const FORMAT_FILE_ID_ERROR: ErrorCode = ErrorCode {
52 code: "format-file-id-error",
53 };
54 pub const OBJECT_STORE_INITIALIZE_ERROR: ErrorCode = ErrorCode {
55 code: "object-store-initialize-error",
56 };
57 pub const OBJECT_REQUEST_ERROR: ErrorCode = ErrorCode {
58 code: "object-request-error",
59 };
60 pub const OBJECT_IO_ERROR: ErrorCode = ErrorCode {
61 code: "object-io-error",
62 };
63 pub const PANIC: ErrorCode = ErrorCode { code: "panic" };
64 pub const ALREADY_CLAIMED: ErrorCode = ErrorCode {
65 code: "already-claimed",
66 };
67 pub const SLED_ERROR: ErrorCode = ErrorCode { code: "sled-error" };
68 pub const SLED_INITIALIZE_ERROR: ErrorCode = ErrorCode {
69 code: "sled-initialize-error",
70 };
71 pub const FJALL_ERROR: ErrorCode = ErrorCode {
72 code: "fjall-error",
73 };
74 pub const FJALL_INITIALIZE_ERROR: ErrorCode = ErrorCode {
75 code: "fjall-initialize-error",
76 };
77 pub const FJALL_DUMP_ERROR: ErrorCode = ErrorCode {
78 code: "fjall-dump-error",
79 };
80 pub const POSTGRES_ERROR: ErrorCode = ErrorCode {
81 code: "postgres-error",
82 };
83 pub const POSTGRES_INITIALIZE_ERROR: ErrorCode = ErrorCode {
84 code: "postgres-initialize-error",
85 };
86 pub const EXTRACT_DETAILS: ErrorCode = ErrorCode {
87 code: "extract-details",
88 };
89 pub const EXTRACT_UPLOAD_RESULT: ErrorCode = ErrorCode {
90 code: "extract-upload-result",
91 };
92 pub const PUSH_JOB: ErrorCode = ErrorCode { code: "push-job" };
93 pub const EXTRACT_JOB: ErrorCode = ErrorCode {
94 code: "extract-job",
95 };
96 pub const CONFLICTED_RECORD: ErrorCode = ErrorCode {
97 code: "conflicted-record",
98 };
99 pub const COMMAND_NOT_FOUND: ErrorCode = ErrorCode {
100 code: "command-not-found",
101 };
102 pub const COMMAND_PERMISSION_DENIED: ErrorCode = ErrorCode {
103 code: "command-permission-denied",
104 };
105 pub const FILE_UPLOAD_ERROR: ErrorCode = ErrorCode {
106 code: "file-upload-error",
107 };
108 pub const IO_ERROR: ErrorCode = ErrorCode { code: "io-error" };
109 pub const VALIDATE_WIDTH: ErrorCode = ErrorCode {
110 code: "validate-width",
111 };
112 pub const VALIDATE_HEIGHT: ErrorCode = ErrorCode {
113 code: "validate-height",
114 };
115 pub const VALIDATE_AREA: ErrorCode = ErrorCode {
116 code: "validate-area",
117 };
118 pub const VALIDATE_FRAMES: ErrorCode = ErrorCode {
119 code: "validate-frames",
120 };
121 pub const VALIDATE_FILE_EMPTY: ErrorCode = ErrorCode {
122 code: "validate-file-empty",
123 };
124 pub const VALIDATE_FILE_SIZE: ErrorCode = ErrorCode {
125 code: "validate-file-size",
126 };
127 pub const VIDEO_DISABLED: ErrorCode = ErrorCode {
128 code: "video-disabled",
129 };
130 pub const MEDIA_DISALLOWED: ErrorCode = ErrorCode {
131 code: "media-disallowed",
132 };
133 pub const HTTP_CLIENT_ERROR: ErrorCode = ErrorCode {
134 code: "http-client-error",
135 };
136 pub const DOWNLOAD_FILE_ERROR: ErrorCode = ErrorCode {
137 code: "download-file-error",
138 };
139 pub const READ_ONLY: ErrorCode = ErrorCode { code: "read-only" };
140 pub const INVALID_FILE_EXTENSION: ErrorCode = ErrorCode {
141 code: "invalid-file-extension",
142 };
143 pub const INVALID_PROCESS_PATH: ErrorCode = ErrorCode {
144 code: "invalid-process-path",
145 };
146 pub const PROCESS_SEMAPHORE_CLOSED: ErrorCode = ErrorCode {
147 code: "process-semaphore-closed",
148 };
149 pub const VALIDATE_NO_FILES: ErrorCode = ErrorCode {
150 code: "validate-no-files",
151 };
152 pub const PROXY_NOT_FOUND: ErrorCode = ErrorCode {
153 code: "proxy-not-found",
154 };
155 pub const PROXY_NOT_ALLOWED: ErrorCode = ErrorCode {
156 code: "proxy-not-allowed",
157 };
158 pub const ALIAS_NOT_FOUND: ErrorCode = ErrorCode {
159 code: "alias-not-found",
160 };
161 pub const LOST_FILE: ErrorCode = ErrorCode { code: "lost-file" };
162 pub const INVALID_DELETE_TOKEN: ErrorCode = ErrorCode {
163 code: "invalid-delete-token",
164 };
165 pub const DUPLICATE_ALIAS: ErrorCode = ErrorCode {
166 code: "duplicate-alias",
167 };
168 pub const RANGE_NOT_SATISFIABLE: ErrorCode = ErrorCode {
169 code: "range-not-satisfiable",
170 };
171 pub const STREAM_TOO_SLOW: ErrorCode = ErrorCode {
172 code: "stream-too-slow",
173 };
174 pub const UNKNOWN_ERROR: ErrorCode = ErrorCode {
175 code: "unknown-error",
176 };
177 pub const FAILED_EXTERNAL_VALIDATION: ErrorCode = ErrorCode {
178 code: "failed-external-validation",
179 };
180 pub const INVALID_JOB: ErrorCode = ErrorCode {
181 code: "invalid-job",
182 };
183 pub const INVALID_QUERY: ErrorCode = ErrorCode {
184 code: "invalid-query",
185 };
186 pub const INVALID_JSON: ErrorCode = ErrorCode {
187 code: "invalid-json",
188 };
189 pub const DECODE_IMAGE: ErrorCode = ErrorCode {
190 code: "decode-image",
191 };
192 pub const INVALID_API_TOKEN: ErrorCode = ErrorCode {
193 code: "invalid-api-token",
194 };
195}