[librsvg: 23/32] impl Error only for public error types




commit 180152e9b989396e4cbf2d30edfd45fcda2d0898
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Nov 27 17:40:23 2020 -0600

    impl Error only for public error types
    
    Private error types are only sometimes printed to log messages; we
    just need the Display trait for that.  Public error types should
    impl Error.
    
    Removed impl Error from these types:
    
      AllowedUrlError
      ElementError
      FilterError
      ParseError

 src/error.rs         | 10 ----------
 src/filters/error.rs |  3 ---
 src/path_parser.rs   |  3 ---
 src/url_resolver.rs  |  3 ---
 4 files changed, 19 deletions(-)
---
diff --git a/src/error.rs b/src/error.rs
index 5d4ce770..53711f45 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -79,16 +79,6 @@ pub struct ElementError {
     pub err: ValueErrorKind,
 }
 
-impl error::Error for ElementError {
-    fn description(&self) -> &str {
-        match self.err {
-            ValueErrorKind::UnknownProperty => "unknown property",
-            ValueErrorKind::Parse(_) => "parse error",
-            ValueErrorKind::Value(_) => "invalid attribute value",
-        }
-    }
-}
-
 impl fmt::Display for ElementError {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "{:?}: {}", self.attr.expanded(), self.err)
diff --git a/src/filters/error.rs b/src/filters/error.rs
index bce600df..9e33424b 100644
--- a/src/filters/error.rs
+++ b/src/filters/error.rs
@@ -1,4 +1,3 @@
-use std::error::Error;
 use std::fmt;
 
 use crate::error::RenderingError;
@@ -25,8 +24,6 @@ pub enum FilterError {
     ChildNodeInError,
 }
 
-impl Error for FilterError {}
-
 impl fmt::Display for FilterError {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match *self {
diff --git a/src/path_parser.rs b/src/path_parser.rs
index 0479efe0..56746a02 100644
--- a/src/path_parser.rs
+++ b/src/path_parser.rs
@@ -1,6 +1,5 @@
 //! Parser for SVG path data.
 
-use std::error::Error;
 use std::fmt;
 use std::iter::Enumerate;
 use std::str;
@@ -853,8 +852,6 @@ pub struct ParseError {
     pub kind: ErrorKind,
 }
 
-impl Error for ParseError {}
-
 impl ParseError {
     fn new(pos: usize, k: ErrorKind) -> ParseError {
         ParseError {
diff --git a/src/url_resolver.rs b/src/url_resolver.rs
index f1ebe928..3a3d749e 100644
--- a/src/url_resolver.rs
+++ b/src/url_resolver.rs
@@ -1,6 +1,5 @@
 //! Determine which URLs are allowed for loading.
 
-use std::error;
 use std::fmt;
 use std::io;
 use std::ops::Deref;
@@ -145,8 +144,6 @@ impl fmt::Display for AllowedUrl {
     }
 }
 
-impl error::Error for AllowedUrlError {}
-
 impl fmt::Display for AllowedUrlError {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match *self {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]