aboutsummaryrefslogtreecommitdiff
path: root/src/api/k2v
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-05-13 15:04:53 +0200
committerAlex Auvolat <alex@adnab.me>2022-05-13 15:04:53 +0200
commit96b11524d53b3616a28f33e2b057655be1639f6f (patch)
tree324a8a9624c5b861fb5a09b0ae0e0c07f6b9614c /src/api/k2v
parentc0fb9fd0fe553e5eda39dcb1a09f059bcd631b6c (diff)
downloadgarage-96b11524d53b3616a28f33e2b057655be1639f6f.tar.gz
garage-96b11524d53b3616a28f33e2b057655be1639f6f.zip
Error refactoring
Diffstat (limited to 'src/api/k2v')
-rw-r--r--src/api/k2v/batch.rs4
-rw-r--r--src/api/k2v/range.rs2
-rw-r--r--src/api/k2v/router.rs4
3 files changed, 5 insertions, 5 deletions
diff --git a/src/api/k2v/batch.rs b/src/api/k2v/batch.rs
index a97bd7f2..26d3cef0 100644
--- a/src/api/k2v/batch.rs
+++ b/src/api/k2v/batch.rs
@@ -88,7 +88,7 @@ async fn handle_read_batch_query(
let (items, more, next_start) = if query.single_item {
if query.prefix.is_some() || query.end.is_some() || query.limit.is_some() || query.reverse {
- return Err(Error::BadRequest("Batch query parameters 'prefix', 'end', 'limit' and 'reverse' must not be set when singleItem is true.".into()));
+ return Err(Error::bad_request("Batch query parameters 'prefix', 'end', 'limit' and 'reverse' must not be set when singleItem is true."));
}
let sk = query
.start
@@ -183,7 +183,7 @@ async fn handle_delete_batch_query(
let deleted_items = if query.single_item {
if query.prefix.is_some() || query.end.is_some() {
- return Err(Error::BadRequest("Batch query parameters 'prefix' and 'end' must not be set when singleItem is true.".into()));
+ return Err(Error::bad_request("Batch query parameters 'prefix' and 'end' must not be set when singleItem is true."));
}
let sk = query
.start
diff --git a/src/api/k2v/range.rs b/src/api/k2v/range.rs
index cd019723..8d4cefbc 100644
--- a/src/api/k2v/range.rs
+++ b/src/api/k2v/range.rs
@@ -31,7 +31,7 @@ where
(None, Some(s)) => (Some(s.clone()), false),
(Some(p), Some(s)) => {
if !s.starts_with(p) {
- return Err(Error::BadRequest(format!(
+ return Err(Error::bad_request(format!(
"Start key '{}' does not start with prefix '{}'",
s, p
)));
diff --git a/src/api/k2v/router.rs b/src/api/k2v/router.rs
index f948ffce..611b6629 100644
--- a/src/api/k2v/router.rs
+++ b/src/api/k2v/router.rs
@@ -62,7 +62,7 @@ impl Endpoint {
.unwrap_or((path.to_owned(), ""));
if bucket.is_empty() {
- return Err(Error::BadRequest("Missing bucket name".to_owned()));
+ return Err(Error::bad_request("Missing bucket name".to_owned()));
}
if *req.method() == Method::OPTIONS {
@@ -83,7 +83,7 @@ impl Endpoint {
Method::PUT => Self::from_put(partition_key, &mut query)?,
Method::DELETE => Self::from_delete(partition_key, &mut query)?,
_ if req.method() == method_search => Self::from_search(partition_key, &mut query)?,
- _ => return Err(Error::BadRequest("Unknown method".to_owned())),
+ _ => return Err(Error::bad_request("Unknown method".to_owned())),
};
if let Some(message) = query.nonempty_message() {