api: Import-rename std::error::Error

This commit is contained in:
Jonas Platte 2020-09-22 01:39:00 +02:00
parent c6d293e0e0
commit bf27285766
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
2 changed files with 16 additions and 10 deletions

View File

@ -2,7 +2,10 @@
//! converting between http requests / responses and ruma's representation of //! converting between http requests / responses and ruma's representation of
//! matrix API requests / responses. //! matrix API requests / responses.
use std::fmt::{self, Display, Formatter}; use std::{
error::Error as StdError,
fmt::{self, Display, Formatter},
};
use crate::EndpointError; use crate::EndpointError;
@ -25,7 +28,7 @@ impl Display for Void {
} }
} }
impl std::error::Error for Void {} impl StdError for Void {}
/// An error when converting one of ruma's endpoint-specific request or response /// An error when converting one of ruma's endpoint-specific request or response
/// types to the corresponding http type. /// types to the corresponding http type.
@ -84,7 +87,7 @@ impl Display for IntoHttpError {
} }
} }
impl std::error::Error for IntoHttpError {} impl StdError for IntoHttpError {}
/// An error when converting a http request to one of ruma's endpoint-specific /// An error when converting a http request to one of ruma's endpoint-specific
/// request types. /// request types.
@ -109,7 +112,7 @@ impl From<RequestDeserializationError> for FromHttpRequestError {
} }
} }
impl std::error::Error for FromHttpRequestError {} impl StdError for FromHttpRequestError {}
/// An error that occurred when trying to deserialize a request. /// An error that occurred when trying to deserialize a request.
#[derive(Debug)] #[derive(Debug)]
@ -135,7 +138,7 @@ impl Display for RequestDeserializationError {
} }
} }
impl std::error::Error for RequestDeserializationError {} impl StdError for RequestDeserializationError {}
/// An error when converting a http response to one of ruma's endpoint-specific /// An error when converting a http response to one of ruma's endpoint-specific
/// response types. /// response types.
@ -169,7 +172,7 @@ impl<E> From<ResponseDeserializationError> for FromHttpResponseError<E> {
} }
} }
impl<E: std::error::Error> std::error::Error for FromHttpResponseError<E> {} impl<E: StdError> StdError for FromHttpResponseError<E> {}
/// An error that occurred when trying to deserialize a response. /// An error that occurred when trying to deserialize a response.
#[derive(Debug)] #[derive(Debug)]
@ -204,7 +207,7 @@ impl Display for ResponseDeserializationError {
} }
} }
impl std::error::Error for ResponseDeserializationError {} impl StdError for ResponseDeserializationError {}
/// An error was reported by the server (HTTP status code 4xx or 5xx) /// An error was reported by the server (HTTP status code 4xx or 5xx)
#[derive(Debug)] #[derive(Debug)]
@ -225,7 +228,7 @@ impl<E: Display> Display for ServerError<E> {
} }
} }
impl<E: std::error::Error> std::error::Error for ServerError<E> {} impl<E: StdError> StdError for ServerError<E> {}
/// An error when converting a http request / response to one of ruma's endpoint-specific request / /// An error when converting a http request / response to one of ruma's endpoint-specific request /
/// response types. /// response types.

View File

@ -14,7 +14,10 @@
#![warn(rust_2018_idioms)] #![warn(rust_2018_idioms)]
#![deny(missing_copy_implementations, missing_debug_implementations, missing_docs)] #![deny(missing_copy_implementations, missing_debug_implementations, missing_docs)]
use std::convert::{TryFrom, TryInto}; use std::{
convert::{TryFrom, TryInto},
error::Error as StdError,
};
use http::Method; use http::Method;
@ -233,7 +236,7 @@ pub trait Outgoing {
} }
/// Gives users the ability to define their own serializable / deserializable errors. /// Gives users the ability to define their own serializable / deserializable errors.
pub trait EndpointError: std::error::Error + Sized { pub trait EndpointError: StdError + Sized {
/// Tries to construct `Self` from an `http::Response`. /// Tries to construct `Self` from an `http::Response`.
/// ///
/// This will always return `Err` variant when no `error` field is defined in /// This will always return `Err` variant when no `error` field is defined in