Skip to content

Commit 81663b7

Browse files
committed
chore: clean up errors
1 parent 633544a commit 81663b7

File tree

10 files changed

+18
-36
lines changed

10 files changed

+18
-36
lines changed

engine/artifacts/errors/guard.actor_destroyed.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

engine/artifacts/errors/guard.actor_not_found.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

engine/artifacts/errors/api.rate_limited.json renamed to engine/artifacts/errors/test.api_rate_limited.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

engine/artifacts/errors/namespace.invalid_name.json renamed to engine/artifacts/errors/test.namespace_invalid_name.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

engine/packages/api-public/src/actors/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub async fn find_dc_for_actor_creation(
141141
// Use user-configured DC
142142
ctx.config()
143143
.dc_for_name(dc_name)
144-
.ok_or_else(|| crate::errors::Datacenter::NotFound.build())?
144+
.ok_or_else(|| rivet_api_util::errors::Datacenter::NotFound.build())?
145145
.datacenter_label
146146
} else {
147147
// Find the nearest DC with runners

engine/packages/api-public/src/errors.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
use rivet_error::*;
22
use serde::{Deserialize, Serialize};
33

4-
#[derive(RivetError, Debug, Deserialize, Serialize)]
5-
#[error("datacenter")]
6-
pub enum Datacenter {
7-
#[error("not_found", "The provided datacenter does not exist.")]
8-
NotFound,
9-
}
10-
114
#[derive(RivetError, Debug, Deserialize, Serialize)]
125
#[error("validation")]
136
pub enum Validation {

engine/packages/api-public/src/runner_configs/upsert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async fn upsert_inner(
9696

9797
// Check for leftover datacenters in the body, this means those datacenters don't exist
9898
if !body.datacenters.is_empty() {
99-
return Err(crate::errors::Datacenter::NotFound.build());
99+
return Err(rivet_api_util::errors::Datacenter::NotFound.build());
100100
}
101101

102102
let any_endpoint_config_changed = futures_util::stream::iter(dcs)

engine/packages/api-util/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rivet_api_builder::{ApiCtx, ErrorResponse, RawErrorResponse, X_RIVET_RAY_ID}
55
use serde::{Serialize, de::DeserializeOwned};
66
use std::future::Future;
77

8-
mod errors;
8+
pub mod errors;
99

1010
pub use axum::http::{HeaderMap, Method};
1111

engine/packages/error/tests/basic.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ fn test_error_chaining() {
121121
// Test struct without formatted description (from derive.rs)
122122
#[derive(RivetError, Serialize, Deserialize)]
123123
#[error(
124-
"namespace",
125-
"invalid_name",
124+
"test",
125+
"namespace_invalid_name",
126126
"
127127
Invalid namespace name.
128128
@@ -144,8 +144,8 @@ fn test_struct_without_formatted_description() {
144144
.build();
145145
let rivet_error = RivetError::extract(&error);
146146

147-
assert_eq!(rivet_error.group(), "namespace");
148-
assert_eq!(rivet_error.code(), "invalid_name");
147+
assert_eq!(rivet_error.group(), "test");
148+
assert_eq!(rivet_error.code(), "namespace_invalid_name");
149149
assert!(rivet_error.message().contains("Invalid namespace name"));
150150
assert!(rivet_error.meta.is_some());
151151

@@ -159,8 +159,8 @@ fn test_struct_without_formatted_description() {
159159
// Test multiline description formatting (from derive.rs)
160160
#[derive(RivetError, Serialize, Deserialize)]
161161
#[error(
162-
"api",
163-
"rate_limited",
162+
"test",
163+
"api_rate_limited",
164164
"
165165
Rate limit exceeded.
166166
@@ -184,8 +184,8 @@ fn test_multiline_descriptions() {
184184
.build();
185185
let rivet_error = RivetError::extract(&error);
186186

187-
assert_eq!(rivet_error.group(), "api");
188-
assert_eq!(rivet_error.code(), "rate_limited");
187+
assert_eq!(rivet_error.group(), "test");
188+
assert_eq!(rivet_error.code(), "api_rate_limited");
189189
assert_eq!(
190190
rivet_error.message(),
191191
"Rate limit exceeded. Limit: 100, resets at: 1234567890"

engine/packages/guard-core/tests/streaming_response.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
mod common;
22

3-
use anyhow::bail;
43
use bytes::Bytes;
54
use futures_util::StreamExt;
65
use http_body_util::{BodyExt, Full};
@@ -246,15 +245,15 @@ fn create_streaming_routing_fn(server_addr: SocketAddr) -> RoutingFn {
246245
path: path.to_string(),
247246
};
248247

249-
Ok(RoutingOutput::Route(RouteConfig {
248+
return Ok(RoutingOutput::Route(RouteConfig {
250249
targets: vec![target],
251250
timeout: RoutingTimeout {
252251
routing_timeout: 30, // 30 seconds for routing timeout
253252
},
254-
}))
253+
}));
255254
}
256255

257-
bail!("bad path");
256+
Err(anyhow::anyhow!("bad path"))
258257
})
259258
},
260259
)

0 commit comments

Comments
 (0)