Missed a couple .unwraps, take them out

master
Paul Woolcock 6 years ago
parent 2d8958e0d9
commit 1c70ecd475
  1. 11
      src/errors.rs
  2. 4
      src/page.rs

@ -1,6 +1,7 @@
use std::{error, fmt, io::Error as IoError}; 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_json::Error as SerdeError;
use serde_urlencoded::ser::Error as UrlEncodedError; use serde_urlencoded::ser::Error as UrlEncodedError;
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
@ -49,6 +50,10 @@ pub enum Error {
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
/// Error deserializing from toml /// Error deserializing from toml
TomlDe(TomlDeError), 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 { impl fmt::Display for Error {
@ -83,6 +88,8 @@ impl error::Error for Error {
Error::TomlSer(ref e) => e.description(), Error::TomlSer(ref e) => e.description(),
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
Error::TomlDe(ref e) => e.description(), 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, ApiError, Api,
#[cfg(feature = "toml")] TomlSerError, TomlSer, #[cfg(feature = "toml")] TomlSerError, TomlSer,
#[cfg(feature = "toml")] TomlDeError, TomlDe, #[cfg(feature = "toml")] TomlDeError, TomlDe,
HeaderStrError, HeaderStrError,
HeaderParseError, HeaderParseError,
} }
#[cfg(test)] #[cfg(test)]

@ -107,9 +107,9 @@ fn get_links(response: &Response) -> Result<(Option<Url>, Option<Url>)> {
let mut next = None; let mut next = None;
if let Some(link_header) = response.headers().get(LINK) { 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_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() { for value in link_header.values() {
if let Some(relations) = value.rel() { if let Some(relations) = value.rel() {
if relations.contains(&RelationType::Next) { if relations.contains(&RelationType::Next) {

Loading…
Cancel
Save