Documentation
#[derive(Debug)]
pub enum BsdlError {
    /// an error occurred in reading the file
    FileError(std::io::Error),
    ///
    ParseError(String),
    PortError,
    IDCodeError(String),
    MissingCharError(String),
    ParenthesisMissingError(String),
    ParenthesisError,
    /// parser expected a quoted string, quotes not found
    QuotesMissingError,
    AttributeError,
    ParseIntError(std::num::ParseIntError),
    GenericError,
    /// error parsing a constant
    ConstantError,
    /// error parsing pinmap
    PinMapErr,
    ///
    NotFoundError,
    /// pin vector out of range
    VecRangeError,
    ///
    OverflowError,
}

impl std::fmt::Display for BsdlError {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            BsdlError::FileError(err) => write!(f, "File error: {}", err),
            BsdlError::ParseError(err) => write!(f, "BSDL parse error: {}", err),
            BsdlError::IDCodeError(err) => write!(f, "JTAG IDCODE error: {}", err),
            BsdlError::AttributeError => write!(f, "BSDL attribute parse error"),
            BsdlError::ParseIntError(_) => write!(f, "BSDL integer parse error"),
            _ => write!(f, "{:?}", self),
        }
    }
}

impl std::error::Error for BsdlError {}

impl From<std::io::Error> for BsdlError {
    fn from(error: std::io::Error) -> Self {
        BsdlError::FileError(error)
    }
}

impl From<std::num::ParseIntError> for BsdlError {
    fn from(e: std::num::ParseIntError) -> Self {
        BsdlError::ParseIntError(e)
    }
}

impl From<jtag_idcode::IDCodeError> for BsdlError {
    fn from(e: jtag_idcode::IDCodeError) -> Self {
        BsdlError::IDCodeError(format!("{e:?}"))
    }
}