-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy patherror.rs
More file actions
230 lines (198 loc) · 5.65 KB
/
error.rs
File metadata and controls
230 lines (198 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
use rivet_error::*;
use serde::{Deserialize, Serialize};
pub fn public_error_status_code(group: &str, code: &str) -> Option<u16> {
match (group, code) {
("auth", "forbidden") => Some(403),
("actor", "action_not_found") => Some(404),
("actor", "action_timed_out") => Some(408),
("actor", "aborted") => Some(400),
("message", "incoming_too_long" | "outgoing_too_long") => Some(400),
(
"queue",
"full"
| "message_too_large"
| "message_invalid"
| "invalid_payload"
| "invalid_completion_payload"
| "already_completed"
| "previous_message_not_completed"
| "complete_not_configured"
| "timed_out",
) => Some(400),
_ => None,
}
}
#[derive(RivetError, Debug, Clone, Deserialize, Serialize)]
#[error("actor")]
pub enum ActorLifecycle {
#[error("starting", "Actor is starting.")]
Starting,
#[error("not_ready", "Actor is not ready.")]
NotReady,
#[error("stopping", "Actor is stopping.")]
Stopping,
#[error("destroying", "Actor is destroying.")]
Destroying,
#[error("shutdown_timeout", "Actor shutdown timed out.")]
ShutdownTimeout,
#[error("dropped_reply", "Actor reply channel was dropped without a response.")]
DroppedReply,
#[error(
"overloaded",
"Actor is overloaded.",
"Actor channel '{channel}' is overloaded while attempting to {operation} (capacity {capacity})."
)]
Overloaded {
channel: String,
capacity: usize,
operation: String,
},
}
#[derive(RivetError, Debug, Clone, Deserialize, Serialize)]
#[error("actor")]
pub enum ActorRuntime {
#[error(
"not_configured",
"Actor capability is not configured.",
"Actor capability '{component}' is not configured."
)]
NotConfigured { component: String },
#[error(
"not_found",
"Actor resource was not found.",
"Actor {resource} '{id}' was not found."
)]
NotFound { resource: String, id: String },
#[error(
"not_registered",
"Actor factory is not registered.",
"Actor factory '{actor_name}' is not registered."
)]
NotRegistered { actor_name: String },
#[error("missing_input", "Actor input is missing.")]
MissingInput,
#[error(
"invalid_operation",
"Actor operation is invalid.",
"Actor operation '{operation}' is invalid: {reason}"
)]
InvalidOperation { operation: String, reason: String },
#[error(
"panicked",
"Actor task panicked.",
"Actor task panicked while running {operation}."
)]
Panicked { operation: String },
}
#[derive(RivetError, Debug, Clone, Deserialize, Serialize)]
#[error("protocol")]
pub(crate) enum ProtocolError {
#[error(
"invalid_http_request",
"Invalid HTTP request.",
"Invalid HTTP request {field}: {reason}"
)]
InvalidHttpRequest { field: String, reason: String },
#[error(
"invalid_http_response",
"Invalid HTTP response.",
"Invalid HTTP response {field}: {reason}"
)]
InvalidHttpResponse { field: String, reason: String },
#[error(
"invalid_actor_connect_request",
"Invalid actor-connect request.",
"Invalid actor-connect request {field}: {reason}"
)]
InvalidActorConnectRequest { field: String, reason: String },
#[error(
"invalid_persisted_data",
"Invalid persisted actor data.",
"Invalid persisted {label}: {reason}"
)]
InvalidPersistedData { label: String, reason: String },
#[error(
"unsupported_encoding",
"Unsupported protocol encoding.",
"Unsupported protocol encoding '{encoding}'."
)]
UnsupportedEncoding { encoding: String },
}
#[derive(RivetError, Debug, Clone, Deserialize, Serialize)]
#[error("sqlite")]
pub(crate) enum SqliteRuntimeError {
#[error(
"unavailable",
"SQLite is unavailable.",
"Actor database is not available because rivetkit-core was built without the sqlite feature."
)]
Unavailable,
#[error("closed", "SQLite database is closed.")]
Closed,
#[error(
"not_configured",
"SQLite is not configured.",
"SQLite {component} is not configured."
)]
NotConfigured { component: String },
#[error(
"invalid_bind_parameter",
"Invalid SQLite bind parameter.",
"Invalid SQLite bind parameter {name}: {reason}"
)]
InvalidBindParameter { name: String, reason: String },
#[error(
"remote_unavailable",
"Remote SQLite is unavailable.",
"Remote SQLite is unavailable: {reason}"
)]
RemoteUnavailable { reason: String },
#[error(
"remote_execution_failed",
"Remote SQLite execution failed.",
"Remote SQLite execution failed: {message}"
)]
RemoteExecutionFailed { message: String },
#[error(
"remote_indeterminate_result",
"Remote SQLite result is indeterminate.",
"Remote SQLite {operation} may have completed, but the envoy disconnected before returning a result."
)]
RemoteIndeterminateResult { operation: String },
#[error(
"remote_fence_mismatch",
"Remote SQLite generation is stale.",
"Remote SQLite generation is stale: {reason}"
)]
RemoteFenceMismatch { reason: String },
}
#[derive(RivetError, Debug, Clone, Deserialize, Serialize)]
#[error("engine")]
pub(crate) enum EngineProcessError {
#[error(
"binary_not_found",
"Engine binary was not found.",
"Engine binary was not found at '{path}'."
)]
BinaryNotFound { path: String },
#[error(
"invalid_endpoint",
"Engine endpoint is invalid.",
"Engine endpoint '{endpoint}' is invalid: {reason}"
)]
InvalidEndpoint { endpoint: String, reason: String },
#[error("missing_pid", "Engine process is missing a pid.")]
MissingPid,
#[error(
"health_check_failed",
"Engine health check failed.",
"Engine health check failed after {attempts} attempts: {reason}"
)]
HealthCheckFailed { attempts: u32, reason: String },
#[error(
"port_occupied",
"Engine port is occupied by a different runtime.",
"Cannot start engine: endpoint '{endpoint}' is already serving runtime '{runtime}'. Stop that process and retry."
)]
PortOccupied { endpoint: String, runtime: String },
}