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(thiserror::Error, Debug)]
14#[non_exhaustive]
15pub enum Error {
16 #[error("the provided Solidity version is not supported: `{0}`")]
18 SolidityUnsupportedVersion(String),
19
20 #[error("there was an error while parsing {path}:{loc}:\n{message}")]
21 ParsingError {
22 path: PathBuf,
23 loc: TextIndex,
24 message: String,
25 },
26
27 #[error("error parsing a semver string: {0}")]
29 SemverParsingError(#[from] semver::Error),
30
31 #[error("error parsing a natspec comment: {message}")]
33 NatspecParsingError {
34 parent: Option<Parent>,
35 span: TextRange,
36 message: String,
37 },
38
39 #[error("`Parse::get_sources` can only be called on the last parser instance")]
42 DanglingParserReferences,
43
44 #[error("IO error for {path:?}: {err}")]
46 IOError { path: PathBuf, err: std::io::Error },
47
48 #[error("unknown error while parsing Solidity")]
50 UnknownError,
51}