[librsvg: 11/18] impl Parse for IRI - return ValueErrorKind, not ParseError



commit 07161815de3071b57c1027773d67b1cb1f3e9203
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Dec 6 17:36:26 2019 -0600

    impl Parse for IRI - return ValueErrorKind, not ParseError
    
    This is for consistency with all the other parsers.

 rsvg_internals/src/iri.rs | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/rsvg_internals/src/iri.rs b/rsvg_internals/src/iri.rs
index e32973f0..9b6b8268 100644
--- a/rsvg_internals/src/iri.rs
+++ b/rsvg_internals/src/iri.rs
@@ -1,6 +1,7 @@
 use cssparser::Parser;
 
 use crate::allowed_url::{Fragment, Href};
+use crate::error::ValueErrorKind;
 use crate::parsers::Parse;
 use crate::parsers::ParseError;
 
@@ -33,25 +34,20 @@ impl IRI {
 }
 
 impl Parse for IRI {
-    type Err = ParseError;
+    type Err = ValueErrorKind;
 
-    fn parse(parser: &mut Parser<'_, '_>) -> Result<IRI, ParseError> {
+    fn parse(parser: &mut Parser<'_, '_>) -> Result<IRI, ValueErrorKind> {
         if parser
             .try_parse(|i| i.expect_ident_matching("none"))
             .is_ok()
         {
             Ok(IRI::None)
         } else {
-            let url = parser
-                .expect_url()
-                .map_err(|_| ParseError::new("expected url"))?;
-
-            parser
-                .expect_exhausted()
-                .map_err(|_| ParseError::new("expected url"))?;
+            let url = parser.expect_url()?;
+            parser.expect_exhausted()?;
 
             match Href::parse(&url).map_err(|_| ParseError::new("could not parse href"))? {
-                Href::PlainUrl(_) => Err(ParseError::new("href requires a fragment identifier")),
+                Href::PlainUrl(_) => Err(ParseError::new("href requires a fragment identifier"))?,
                 Href::WithFragment(f) => Ok(IRI::Resource(f)),
             }
         }


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