[librsvg: 3/51] lighting.rs: Don't use NodeError directly



commit 3f5ec7387b0355759ec1852df47d087ad472281a
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Dec 16 20:03:58 2019 -0600

    lighting.rs: Don't use NodeError directly

 rsvg_internals/src/filters/light/lighting.rs | 29 ++++++++++++----------------
 1 file changed, 12 insertions(+), 17 deletions(-)
---
diff --git a/rsvg_internals/src/filters/light/lighting.rs b/rsvg_internals/src/filters/light/lighting.rs
index e432fb1c..01e3d855 100644
--- a/rsvg_internals/src/filters/light/lighting.rs
+++ b/rsvg_internals/src/filters/light/lighting.rs
@@ -8,7 +8,7 @@ use num_traits::identities::Zero;
 use rayon::prelude::*;
 
 use crate::drawing_ctx::DrawingCtx;
-use crate::error::{AttributeResultExt, NodeError};
+use crate::error::*;
 use crate::filters::{
     context::{FilterContext, FilterOutput, FilterResult},
     light::{
@@ -73,17 +73,16 @@ impl Common {
                 expanded_name!(svg "kernelUnitLength") => {
                     self.kernel_unit_length = Some(
                         parsers::number_optional_number(value)
-                            .attribute(attr.clone())
                             .and_then(|(x, y)| {
                                 if x > 0.0 && y > 0.0 {
                                     Ok((x, y))
                                 } else {
-                                    Err(NodeError::value_error(
-                                        attr,
+                                    Err(ValueErrorKind::value_error(
                                         "kernelUnitLength can't be less or equal to zero",
                                     ))
                                 }
-                            })?,
+                            })
+                            .attribute(attr)?,
                     )
                 }
                 _ => (),
@@ -119,17 +118,16 @@ impl NodeTrait for FeDiffuseLighting {
             match attr.expanded() {
                 expanded_name!(svg "diffuseConstant") => {
                     self.diffuse_constant = parsers::number(value)
-                        .attribute(attr.clone())
                         .and_then(|x| {
                             if x >= 0.0 {
                                 Ok(x)
                             } else {
-                                Err(NodeError::value_error(
-                                    attr,
+                                Err(ValueErrorKind::value_error(
                                     "diffuseConstant can't be negative",
                                 ))
                             }
-                        })?;
+                        })
+                        .attribute(attr)?;
                 }
                 _ => (),
             }
@@ -191,31 +189,28 @@ impl NodeTrait for FeSpecularLighting {
             match attr.expanded() {
                 expanded_name!(svg "specularConstant") => {
                     self.specular_constant = parsers::number(value)
-                        .attribute(attr.clone())
                         .and_then(|x| {
                             if x >= 0.0 {
                                 Ok(x)
                             } else {
-                                Err(NodeError::value_error(
-                                    attr,
+                                Err(ValueErrorKind::value_error(
                                     "specularConstant can't be negative",
                                 ))
                             }
-                        })?;
+                        })
+                        .attribute(attr)?;
                 }
                 expanded_name!(svg "specularExponent") => {
                     self.specular_exponent = parsers::number(value)
-                        .attribute(attr.clone())
                         .and_then(|x| {
                             if x >= 1.0 && x <= 128.0 {
                                 Ok(x)
                             } else {
-                                Err(NodeError::value_error(
-                                    attr,
+                                Err(ValueErrorKind::value_error(
                                     "specularExponent should be between 1.0 and 128.0",
                                 ))
                             }
-                        })?;
+                        }).attribute(attr)?;
                 }
                 _ => (),
             }


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