aboutsummaryrefslogblamecommitdiffstats
path: root/src/error.rs
blob: 2d966664306b8752655bb87b72659d61ae60bf76 (plain) (tree)
1
2
3
4
5
6
7
8
9

                                              
                                                 
 
                



                              


                                                   
                                                        


                                     
                         
                      












                                        





                                           
use std::{num::ParseIntError, str::Utf8Error};

use crate::element::{Name, NamespaceDeclaration};

#[derive(Debug)]
pub enum Error {
    ReadError(std::io::Error),
    Utf8Error(Utf8Error),
    ParseError(String),
    EntityProcessError(String),
    // TODO: better choice for failures than string
    InvalidCharRef(String),
    DuplicateNameSpaceDeclaration(NamespaceDeclaration),
    DuplicateAttribute(String),
    UnqualifiedNamespace(String),
    MismatchedEndTag(String, String),
    NotInElement(String),
    ExtraData(String),
}

impl From<std::io::Error> for Error {
    fn from(e: std::io::Error) -> Self {
        Self::ReadError(e)
    }
}

impl From<Utf8Error> for Error {
    fn from(e: Utf8Error) -> Self {
        Self::Utf8Error(e)
    }
}

impl From<ParseIntError> for Error {
    fn from(e: ParseIntError) -> Self {
        Self::InvalidCharRef(e.to_string())
    }
}