Skip to content

Commit 85a5089

Browse files
committed
changes from feedback, use bail_status
1 parent 63a7be9 commit 85a5089

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/content/content_location.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::headers::{HeaderName, HeaderValue, Headers, CONTENT_LOCATION};
2-
use crate::{Error, StatusCode};
3-
use crate::{Status, Url};
2+
use crate::{bail_status as bail, Status, Url};
43

54
use std::convert::TryInto;
65

@@ -54,11 +53,10 @@ impl ContentLocation {
5453
// If we successfully parsed the header then there's always at least one
5554
// entry. We want the last entry.
5655
let value = headers.iter().last().unwrap();
57-
let base = base_url.try_into().map_err(|_| {
58-
let mut err = Error::new_adhoc("Invalid base url provided");
59-
err.set_status(StatusCode::BadRequest);
60-
err
61-
})?;
56+
let base = match base_url.try_into() {
57+
Ok(b) => b,
58+
Err(_) => bail!(400, "Invalid base url provided"),
59+
};
6260

6361
let url = base.join(value.as_str().trim()).status(400)?;
6462
Ok(Some(Self { url }))

0 commit comments

Comments
 (0)