1use core::fmt;
2use std::string::FromUtf8Error;
3
4use lalrpop_util::ParseError;
5use thiserror::Error as ThisError;
6
7#[derive(Debug, ThisError)]
8pub enum Error {
9 #[error("Failed to parse the contract. {0}")]
10 ParseError(String),
11
12 #[error("Failed to visit AST {0}")]
13 AstVisitError(String),
14
15 #[error(transparent)]
16 IoError(#[from] std::io::Error),
17
18 #[error(transparent)]
19 FromUtf8Error(#[from] FromUtf8Error),
20}
21
22impl<L, T, E> From<ParseError<L, T, E>> for Error
23where
24 L: fmt::Debug,
25 T: fmt::Debug,
26 E: fmt::Debug,
27{
28 fn from(value: ParseError<L, T, E>) -> Self {
29 Self::ParseError(format!("{:?}", value))
30 }
31}