1use crate::ElementExt;
2
3pub struct UnsupportedError(String, String);
4
5impl crate::DisplayError for UnsupportedError {
6 fn format(&self, w: &mut dyn std::io::Write) -> std::io::Result<()> {
7 let maybe_styled_element = {
8 cfg_if::cfg_if! {
9 if #[cfg(feature = "cli")] {
10 use colored::Colorize;
11 self.1.dimmed()
12 } else {
13 &self.1
14 }
15 }
16 };
17 write!(
18 w,
19 "{} is unsupported in element\n {}",
20 self.0, maybe_styled_element,
21 )
22 }
23}
24
25impl UnsupportedError {
26 pub fn new<S: Into<String>>(what: S, el: &xmltree::Element) -> Self {
27 UnsupportedError(what.into(), el.debug())
28 }
29}