diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-09-25 18:20:39 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-09-25 18:20:39 +0200 |
| commit | f6adc45638409aaa0feb1f70883c11ed553efe4f (patch) | |
| tree | 3691cec70698a1952f2b315ed8b602912739acce /src/image.rs | |
| parent | fffb55f79a3369fa2dcf39371091c48ff61f55a8 (diff) | |
XML reading
Diffstat (limited to 'src/image.rs')
| -rw-r--r-- | src/image.rs | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/src/image.rs b/src/image.rs index 717b1a93..ae4d165f 100644 --- a/src/image.rs +++ b/src/image.rs @@ -2,7 +2,7 @@ use std::io; -use crate::diag::StrResult; +use crate::diag::{format_xml_like_error, StrResult}; use crate::util::Buffer; /// A raster or vector image. @@ -161,31 +161,6 @@ fn format_usvg_error(error: usvg::Error) -> String { usvg::Error::InvalidSize => { "failed to parse svg: width, height, or viewbox is invalid".into() } - usvg::Error::ParsingFailed(error) => match error { - roxmltree::Error::UnexpectedCloseTag { expected, actual, pos } => { - format!( - "failed to parse svg: found closing tag '{actual}' \ - instead of '{expected}' in line {}", - pos.row - ) - } - roxmltree::Error::UnknownEntityReference(entity, pos) => { - format!( - "failed to parse svg: unknown entity '{entity}' in line {}", - pos.row - ) - } - roxmltree::Error::DuplicatedAttribute(attr, pos) => { - format!( - "failed to parse svg: duplicate attribute '{attr}' in line {}", - pos.row - ) - } - roxmltree::Error::NoRootNode => { - "failed to parse svg: missing root node".into() - } - roxmltree::Error::SizeLimit => "file is too large".into(), - _ => "failed to parse svg".into(), - }, + usvg::Error::ParsingFailed(error) => format_xml_like_error("svg", error), } } |
