pdx_syntax/
result.rs

1//! Warpper for parser result.
2//!
3pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
4
5/// Error type.
6/// - ParseError: parsing failed. This is formated to [`String`].
7/// - IoError: IO error.
8#[derive(Debug)]
9pub enum Error {
10    ParseError(String),
11    IoError(std::io::Error),
12}
13
14impl core::fmt::Display for Error {
15    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16        match self { 
17            Error::ParseError(e) => write!(f, "ParseError: {}", e),
18            Error::IoError(e) => write!(f, "IoError: {}", e),
19        }
20    }
21}
22
23impl std::error::Error for Error {}