From 105e3542991aef5f1654fe260f9fa53a32f622f2 Mon Sep 17 00:00:00 2001 From: Dom Dwyer Date: Thu, 26 Jan 2023 16:44:10 +0100 Subject: [PATCH] refactor: clean up namespace errors The namespace error was poorly refactored and duplicated the prefix string. The "rejected" case is now also tested. --- router/src/server/http.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/router/src/server/http.rs b/router/src/server/http.rs index b0724f2d49..fe43b14dc6 100644 --- a/router/src/server/http.rs +++ b/router/src/server/http.rs @@ -85,7 +85,7 @@ pub enum Error { /// name into a [`NamespaceId`]. /// /// [`NamespaceId`]: data_types::NamespaceId - #[error("failed to resolve namespace ID: {0}")] + #[error(transparent)] NamespaceResolver(#[from] crate::namespace_resolver::Error), /// The router is currently servicing the maximum permitted number of @@ -561,7 +561,7 @@ mod tests { use super::*; use crate::{ dml_handlers::mock::{MockDmlHandler, MockDmlHandlerCall}, - namespace_resolver::mock::MockNamespaceResolver, + namespace_resolver::{mock::MockNamespaceResolver, NamespaceCreationError}, }; use assert_matches::assert_matches; use data_types::{NamespaceId, NamespaceNameError}; @@ -1513,10 +1513,16 @@ mod tests { crate::namespace_resolver::Error::Lookup(e) }), "failed to resolve namespace ID: \ - failed to resolve namespace ID: \ name [name] already exists", ), + ( + NamespaceResolver( + crate::namespace_resolver::Error::Create(NamespaceCreationError::Reject("bananas".to_string())) + ), + "rejecting write due to non-existing namespace: bananas", + ), + ( RequestLimit, "this service is overloaded, please try again later",