[librsvg: 13/51] color_matrix.rs: Don't create NodeError directly
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 13/51] color_matrix.rs: Don't create NodeError directly
- Date: Thu, 19 Dec 2019 01:49:06 +0000 (UTC)
commit 54f2f49a2905850ad82ee2c73fc3b58c6f8d3b93
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Dec 17 10:53:50 2019 -0600
color_matrix.rs: Don't create NodeError directly
rsvg_internals/src/filters/color_matrix.rs | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/rsvg_internals/src/filters/color_matrix.rs b/rsvg_internals/src/filters/color_matrix.rs
index 4a8492e6..8198667a 100644
--- a/rsvg_internals/src/filters/color_matrix.rs
+++ b/rsvg_internals/src/filters/color_matrix.rs
@@ -3,7 +3,7 @@ use markup5ever::{expanded_name, local_name, namespace_url, ns, QualName};
use nalgebra::{Matrix3, Matrix4x5, Matrix5, Vector5};
use crate::drawing_ctx::DrawingCtx;
-use crate::error::{AttributeResultExt, NodeError};
+use crate::error::*;
use crate::node::{NodeResult, NodeTrait, RsvgNode};
use crate::number_list::{NumberList, NumberListError, NumberListLength};
use crate::parsers;
@@ -79,8 +79,8 @@ impl NodeTrait for FeColorMatrix {
OperationType::LuminanceToAlpha => unreachable!(),
OperationType::Matrix => {
let NumberList(v) =
- NumberList::parse_str(value, NumberListLength::Exact(20)).map_err(
- |err| {
+ NumberList::parse_str(value, NumberListLength::Exact(20))
+ .map_err(|err| {
let err_str = match err {
NumberListError::IncorrectNumberOfElements => {
"incorrect number of elements: expected 20"
@@ -88,9 +88,9 @@ impl NodeTrait for FeColorMatrix {
NumberListError::Parse(ref err) => &err,
};
- NodeError::parse_error(attr, err_str)
- },
- )?;
+ ValueErrorKind::parse_error(err_str)
+ })
+ .attribute(attr)?;
let matrix = Matrix4x5::from_row_slice(&v);
let mut matrix = matrix.fixed_resize(0.0);
matrix[(4, 4)] = 1.0;
@@ -99,7 +99,8 @@ impl NodeTrait for FeColorMatrix {
OperationType::Saturate => {
let s = parsers::number(value).attribute(attr.clone())?;
if s < 0.0 || s > 1.0 {
- return Err(NodeError::value_error(attr, "expected value from 0 to 1"));
+ return Err(ValueErrorKind::value_error("expected value from 0 to 1"))
+ .attribute(attr);
}
#[cfg_attr(rustfmt, rustfmt_skip)]
@@ -231,7 +232,7 @@ impl OperationType {
"saturate" => Ok(OperationType::Saturate),
"hueRotate" => Ok(OperationType::HueRotate),
"luminanceToAlpha" => Ok(OperationType::LuminanceToAlpha),
- _ => Err(NodeError::parse_error(attr, "invalid value")),
+ _ => Err(ValueErrorKind::parse_error("invalid value")).attribute(attr),
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]