summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Woolcock <paul@woolcock.us>2018-10-03 05:32:34 -0400
committerPaul Woolcock <paul@woolcock.us>2018-10-03 12:48:50 -0400
commit1c70ecd475602000a4f440dcd8c67fefd821b133 (patch)
tree6c571dbce2ff4c938bbb3b0950c4c04b77aad93c
parent2d8958e0d90cb1206df6d28eab8b4294602184e3 (diff)
Missed a couple .unwraps, take them out
-rw-r--r--src/errors.rs11
-rw-r--r--src/page.rs4
2 files changed, 12 insertions, 3 deletions
diff --git a/src/errors.rs b/src/errors.rs
index 7c82043..2c466ef 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -1,6 +1,7 @@
use std::{error, fmt, io::Error as IoError};
-use reqwest::{Error as HttpError, StatusCode};
+use hyper_old_types::Error as HeaderParseError;
+use reqwest::{header::ToStrError as HeaderStrError, Error as HttpError, StatusCode};
use serde_json::Error as SerdeError;
use serde_urlencoded::ser::Error as UrlEncodedError;
#[cfg(feature = "toml")]
@@ -49,6 +50,10 @@ pub enum Error {
#[cfg(feature = "toml")]
/// Error deserializing from toml
TomlDe(TomlDeError),
+ /// Error converting an http header to a string
+ HeaderStrError(HeaderStrError),
+ /// Error parsing the http Link header
+ HeaderParseError(HeaderParseError),
}
impl fmt::Display for Error {
@@ -83,6 +88,8 @@ impl error::Error for Error {
Error::TomlSer(ref e) => e.description(),
#[cfg(feature = "toml")]
Error::TomlDe(ref e) => e.description(),
+ Error::HeaderStrError(ref e) => e.description(),
+ Error::HeaderParseError(ref e) => e.description(),
}
}
}
@@ -119,6 +126,8 @@ from! {
ApiError, Api,
#[cfg(feature = "toml")] TomlSerError, TomlSer,
#[cfg(feature = "toml")] TomlDeError, TomlDe,
+ HeaderStrError, HeaderStrError,
+ HeaderParseError, HeaderParseError,
}
#[cfg(test)]
diff --git a/src/page.rs b/src/page.rs
index cab4e09..7733311 100644
--- a/src/page.rs
+++ b/src/page.rs
@@ -107,9 +107,9 @@ fn get_links(response: &Response) -> Result<(Option<Url>, Option<Url>)> {
let mut next = None;
if let Some(link_header) = response.headers().get(LINK) {
- let link_header = link_header.to_str().unwrap();
+ let link_header = link_header.to_str()?;
let link_header = link_header.as_bytes();
- let link_header: Link = parsing::from_raw_str(&link_header).unwrap();
+ let link_header: Link = parsing::from_raw_str(&link_header)?;
for value in link_header.values() {
if let Some(relations) = value.rel() {
if relations.contains(&RelationType::Next) {