graph: Derive Fail for SubscriptionError
use serde::ser::*;
-use std::error::Error;
-use std::fmt;
use prelude::QueryExecutionError;
/// Error caused while processing a [Subscription](struct.Subscription.html) request.
-#[derive(Debug)]
+#[derive(Debug, Fail)]
pub enum SubscriptionError {
+ #[fail(display = "GraphQL error: {}", _0)]
GraphQLError(QueryExecutionError),
}
@@ -16,26 +15,6 @@ impl From<QueryExecutionError> for SubscriptionError {
}
}
-impl Error for SubscriptionError {
- fn description(&self) -> &str {
- "Subscription error"
- }
-
- fn cause(&self) -> Option<&Error> {
- match self {
- SubscriptionError::GraphQLError(e) => Some(e),
- }
- }
-}
-
-impl fmt::Display for SubscriptionError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- SubscriptionError::GraphQLError(e) => write!(f, "{}", e),
- }
- }
-}
-
impl Serialize for SubscriptionError {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
