1use std::path::PathBuf;
3
4use crate::{
5 definitions::Parent,
6 textindex::{TextIndex, TextRange},
7};
8
9pub type Result<T> = std::result::Result<T, Error>;
11
12#[derive(Debug, thiserror::Error, thiserror_ext::Box)]
14#[thiserror_ext(newtype(name = Error))]
15#[non_exhaustive]
16pub enum ErrorKind {
17 #[error("the provided Solidity version is not supported: `{0}`")]
19 SolidityUnsupportedVersion(String),
20
21 #[error("there was an error while parsing {path}:{loc}:\n{message}")]
22 ParsingError {
23 path: PathBuf,
24 loc: TextIndex,
25 message: String,
26 },
27
28 #[error("error parsing a semver string: {0}")]
30 SemverParsingError(#[from] semver::Error),
31
32 #[error("error parsing a natspec comment: {message}")]
34 NatspecParsingError {
35 parent: Option<Parent>,
36 span: TextRange,
37 message: String,
38 },
39
40 #[error("`Parse::get_sources` can only be called on the last parser instance")]
43 DanglingParserReferences,
44
45 #[error("IO error for {path:?}: {err}")]
47 IOError { path: PathBuf, err: std::io::Error },
48
49 #[error("unknown error while parsing Solidity")]
51 UnknownError,
52}