Skip to main content

junit_report/
error.rs

1/*
2 * Copyright (c) 2018 Pascal Bach
3 * Copyright (c) 2021 Siemens Mobility GmbH
4 *
5 * SPDX-License-Identifier:     MIT
6 */
7
8#[derive(Debug)]
9pub enum Error {
10    Xml(quick_xml::Error),
11    Io(std::io::Error),
12}
13
14impl std::fmt::Display for Error {
15    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16        match self {
17            Error::Xml(e) => write!(f, "XML error: {e}"),
18            Error::Io(e) => write!(f, "IO error: {e}"),
19        }
20    }
21}
22
23impl std::error::Error for Error {}
24
25impl From<quick_xml::Error> for Error {
26    fn from(e: quick_xml::Error) -> Self {
27        Error::Xml(e)
28    }
29}
30
31impl From<std::io::Error> for Error {
32    fn from(e: std::io::Error) -> Self {
33        Error::Io(e)
34    }
35}