aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3/website.rs
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/s3/website.rs
parentc0fb9fd0fe553e5eda39dcb1a09f059bcd631b6c (diff)
downloadgarage-96b11524d53b3616a28f33e2b057655be1639f6f.tar.gz
garage-96b11524d53b3616a28f33e2b057655be1639f6f.zip
Error refactoring
Diffstat (limited to 'src/api/s3/website.rs')
-rw-r--r--src/api/s3/website.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/api/s3/website.rs b/src/api/s3/website.rs
index 561130dc..4fc7b7bb 100644
--- a/src/api/s3/website.rs
+++ b/src/api/s3/website.rs
@@ -176,7 +176,7 @@ impl WebsiteConfiguration {
|| self.index_document.is_some()
|| self.routing_rules.is_some())
{
- return Err(Error::BadRequest(
+ return Err(Error::bad_request(
"Bad XML: can't have RedirectAllRequestsTo and other fields".to_owned(),
));
}
@@ -222,7 +222,7 @@ impl WebsiteConfiguration {
impl Key {
pub fn validate(&self) -> Result<(), Error> {
if self.key.0.is_empty() {
- Err(Error::BadRequest(
+ Err(Error::bad_request(
"Bad XML: error document specified but empty".to_owned(),
))
} else {
@@ -234,7 +234,7 @@ impl Key {
impl Suffix {
pub fn validate(&self) -> Result<(), Error> {
if self.suffix.0.is_empty() | self.suffix.0.contains('/') {
- Err(Error::BadRequest(
+ Err(Error::bad_request(
"Bad XML: index document is empty or contains /".to_owned(),
))
} else {
@@ -247,7 +247,7 @@ impl Target {
pub fn validate(&self) -> Result<(), Error> {
if let Some(ref protocol) = self.protocol {
if protocol.0 != "http" && protocol.0 != "https" {
- return Err(Error::BadRequest("Bad XML: invalid protocol".to_owned()));
+ return Err(Error::bad_request("Bad XML: invalid protocol".to_owned()));
}
}
Ok(())
@@ -269,19 +269,19 @@ impl Redirect {
pub fn validate(&self, has_prefix: bool) -> Result<(), Error> {
if self.replace_prefix.is_some() {
if self.replace_full.is_some() {
- return Err(Error::BadRequest(
+ return Err(Error::bad_request(
"Bad XML: both ReplaceKeyPrefixWith and ReplaceKeyWith are set".to_owned(),
));
}
if !has_prefix {
- return Err(Error::BadRequest(
+ return Err(Error::bad_request(
"Bad XML: ReplaceKeyPrefixWith is set, but KeyPrefixEquals isn't".to_owned(),
));
}
}
if let Some(ref protocol) = self.protocol {
if protocol.0 != "http" && protocol.0 != "https" {
- return Err(Error::BadRequest("Bad XML: invalid protocol".to_owned()));
+ return Err(Error::bad_request("Bad XML: invalid protocol".to_owned()));
}
}
// TODO there are probably more invalide cases, but which ones?