diff --git a/engine/artifacts/errors/guard.actor_destroyed.json b/engine/artifacts/errors/guard.actor_destroyed.json deleted file mode 100644 index d940d8cd6d..0000000000 --- a/engine/artifacts/errors/guard.actor_destroyed.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "code": "actor_destroyed", - "group": "guard", - "message": "Actor destroyed." -} \ No newline at end of file diff --git a/engine/artifacts/errors/guard.actor_not_found.json b/engine/artifacts/errors/guard.actor_not_found.json deleted file mode 100644 index 987d6e6727..0000000000 --- a/engine/artifacts/errors/guard.actor_not_found.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "code": "actor_not_found", - "group": "guard", - "message": "Actor not found." -} \ No newline at end of file diff --git a/engine/artifacts/errors/api.rate_limited.json b/engine/artifacts/errors/test.api_rate_limited.json similarity index 76% rename from engine/artifacts/errors/api.rate_limited.json rename to engine/artifacts/errors/test.api_rate_limited.json index 4f42c1974d..8d2efbe711 100644 --- a/engine/artifacts/errors/api.rate_limited.json +++ b/engine/artifacts/errors/test.api_rate_limited.json @@ -1,5 +1,5 @@ { - "code": "rate_limited", - "group": "api", + "code": "api_rate_limited", + "group": "test", "message": "\n\tRate limit exceeded.\n\t\n\tThe API rate limit has been exceeded for this endpoint.\n\tPlease wait before making additional requests.\n\t" } \ No newline at end of file diff --git a/engine/artifacts/errors/namespace.invalid_name.json b/engine/artifacts/errors/test.namespace_invalid_name.json similarity index 65% rename from engine/artifacts/errors/namespace.invalid_name.json rename to engine/artifacts/errors/test.namespace_invalid_name.json index 537dba4c8f..2770555160 100644 --- a/engine/artifacts/errors/namespace.invalid_name.json +++ b/engine/artifacts/errors/test.namespace_invalid_name.json @@ -1,5 +1,5 @@ { - "code": "invalid_name", - "group": "namespace", + "code": "namespace_invalid_name", + "group": "test", "message": "\n\tInvalid namespace name.\n\t\n\tNamespace names must be valid DNS subdomains.\n\t" } \ No newline at end of file diff --git a/engine/packages/api-public/src/actors/utils.rs b/engine/packages/api-public/src/actors/utils.rs index 59b1e97100..612e2596b2 100644 --- a/engine/packages/api-public/src/actors/utils.rs +++ b/engine/packages/api-public/src/actors/utils.rs @@ -141,7 +141,7 @@ pub async fn find_dc_for_actor_creation( // Use user-configured DC ctx.config() .dc_for_name(dc_name) - .ok_or_else(|| crate::errors::Datacenter::NotFound.build())? + .ok_or_else(|| rivet_api_util::errors::Datacenter::NotFound.build())? .datacenter_label } else { // Find the nearest DC with runners diff --git a/engine/packages/api-public/src/errors.rs b/engine/packages/api-public/src/errors.rs index bfe370963e..3a4bc5f7cc 100644 --- a/engine/packages/api-public/src/errors.rs +++ b/engine/packages/api-public/src/errors.rs @@ -1,13 +1,6 @@ use rivet_error::*; use serde::{Deserialize, Serialize}; -#[derive(RivetError, Debug, Deserialize, Serialize)] -#[error("datacenter")] -pub enum Datacenter { - #[error("not_found", "The provided datacenter does not exist.")] - NotFound, -} - #[derive(RivetError, Debug, Deserialize, Serialize)] #[error("validation")] pub enum Validation { diff --git a/engine/packages/api-public/src/runner_configs/upsert.rs b/engine/packages/api-public/src/runner_configs/upsert.rs index 212f3ebcae..3f03d40842 100644 --- a/engine/packages/api-public/src/runner_configs/upsert.rs +++ b/engine/packages/api-public/src/runner_configs/upsert.rs @@ -96,7 +96,7 @@ async fn upsert_inner( // Check for leftover datacenters in the body, this means those datacenters don't exist if !body.datacenters.is_empty() { - return Err(crate::errors::Datacenter::NotFound.build()); + return Err(rivet_api_util::errors::Datacenter::NotFound.build()); } let any_endpoint_config_changed = futures_util::stream::iter(dcs) diff --git a/engine/packages/api-util/src/lib.rs b/engine/packages/api-util/src/lib.rs index cbc745a286..118a78ad12 100644 --- a/engine/packages/api-util/src/lib.rs +++ b/engine/packages/api-util/src/lib.rs @@ -5,7 +5,7 @@ use rivet_api_builder::{ApiCtx, ErrorResponse, RawErrorResponse, X_RIVET_RAY_ID} use serde::{Serialize, de::DeserializeOwned}; use std::future::Future; -mod errors; +pub mod errors; pub use axum::http::{HeaderMap, Method}; diff --git a/engine/packages/error/tests/basic.rs b/engine/packages/error/tests/basic.rs index 2467a936a2..e7fd0fe702 100644 --- a/engine/packages/error/tests/basic.rs +++ b/engine/packages/error/tests/basic.rs @@ -121,8 +121,8 @@ fn test_error_chaining() { // Test struct without formatted description (from derive.rs) #[derive(RivetError, Serialize, Deserialize)] #[error( - "namespace", - "invalid_name", + "test", + "namespace_invalid_name", " Invalid namespace name. @@ -144,8 +144,8 @@ fn test_struct_without_formatted_description() { .build(); let rivet_error = RivetError::extract(&error); - assert_eq!(rivet_error.group(), "namespace"); - assert_eq!(rivet_error.code(), "invalid_name"); + assert_eq!(rivet_error.group(), "test"); + assert_eq!(rivet_error.code(), "namespace_invalid_name"); assert!(rivet_error.message().contains("Invalid namespace name")); assert!(rivet_error.meta.is_some()); @@ -159,8 +159,8 @@ fn test_struct_without_formatted_description() { // Test multiline description formatting (from derive.rs) #[derive(RivetError, Serialize, Deserialize)] #[error( - "api", - "rate_limited", + "test", + "api_rate_limited", " Rate limit exceeded. @@ -184,8 +184,8 @@ fn test_multiline_descriptions() { .build(); let rivet_error = RivetError::extract(&error); - assert_eq!(rivet_error.group(), "api"); - assert_eq!(rivet_error.code(), "rate_limited"); + assert_eq!(rivet_error.group(), "test"); + assert_eq!(rivet_error.code(), "api_rate_limited"); assert_eq!( rivet_error.message(), "Rate limit exceeded. Limit: 100, resets at: 1234567890" diff --git a/engine/packages/guard-core/tests/streaming_response.rs b/engine/packages/guard-core/tests/streaming_response.rs index 040b3c999a..41b59c148c 100644 --- a/engine/packages/guard-core/tests/streaming_response.rs +++ b/engine/packages/guard-core/tests/streaming_response.rs @@ -1,6 +1,5 @@ mod common; -use anyhow::bail; use bytes::Bytes; use futures_util::StreamExt; use http_body_util::{BodyExt, Full}; @@ -246,15 +245,15 @@ fn create_streaming_routing_fn(server_addr: SocketAddr) -> RoutingFn { path: path.to_string(), }; - Ok(RoutingOutput::Route(RouteConfig { + return Ok(RoutingOutput::Route(RouteConfig { targets: vec![target], timeout: RoutingTimeout { routing_timeout: 30, // 30 seconds for routing timeout }, - })) + })); } - bail!("bad path"); + Err(anyhow::anyhow!("bad path")) }) }, )