error docs touchups

This commit is contained in:
Sean McArthur
2017-06-11 11:03:15 -07:00
parent c8d03dd8b9
commit 8633060eaf

View File

@@ -67,16 +67,13 @@ impl Error {
/// # fn run() { /// # fn run() {
/// // displays last stop of a redirect loop /// // displays last stop of a redirect loop
/// let response = reqwest::get("http://site.with.redirect.loop"); /// let response = reqwest::get("http://site.with.redirect.loop");
/// match response { /// if let Err(e) = response {
/// Err(e) => if e.is_redirect() { /// if e.is_redirect() {
/// let final_stop = match e.url() { /// if let Some(final_stop) = e.url() {
/// Some(url) => url, /// println!("redirect loop at {}", final_stop);
/// None => return, /// }
/// }; /// }
/// println!("Last redirect led to: {}", final_stop); /// }
/// },
/// _ => return,
/// };
/// # } /// # }
/// ``` /// ```
#[inline] #[inline]
@@ -92,21 +89,23 @@ impl Error {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// extern crate url;
/// # extern crate reqwest;
/// // retries requests with no host on localhost /// // retries requests with no host on localhost
/// # fn run() { /// # fn run() {
/// let invalid_request = "http://"; /// let invalid_request = "http://";
/// let mut response = reqwest::get(invalid_request); /// let mut response = reqwest::get(invalid_request);
/// match response { /// if let Err(e) = response {
/// Err(e) => match e.get_ref() { /// match e.get_ref().and_then(|e| e.downcast_ref::<url::ParseError>()) {
/// Some(internal_error) => if internal_error.description() == "empty host" { /// Some(&url::ParseError::EmptyHost) => {
/// let valid_request = format!("{}{}",invalid_request, "localhost"); /// let valid_request = format!("{}{}",invalid_request, "localhost");
/// response = reqwest::get(&valid_request); /// response = reqwest::get(&valid_request);
/// }, /// },
/// _ => return, /// _ => (),
/// }, /// }
/// _ => return, /// }
/// };
/// # } /// # }
/// # fn main() {}
/// ``` /// ```
#[inline] #[inline]
pub fn get_ref(&self) -> Option<&(StdError + Send + Sync + 'static)> { pub fn get_ref(&self) -> Option<&(StdError + Send + Sync + 'static)> {