use std::path::PathBuf;
use crate::{
definitions::Parent,
textindex::{TextIndex, TextRange},
};
pub type Result<T> = std::result::Result<T, Error>;
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error("the provided Solidity version is not supported: `{0}`")]
SolidityUnsupportedVersion(String),
#[error("there was an error while parsing {path}:{loc}:\n{message}")]
ParsingError {
path: PathBuf,
loc: TextIndex,
message: String,
},
#[error("error parsing a semver string: {0}")]
SemverParsingError(#[from] semver::Error),
#[error("error parsing a natspec comment: {message}")]
NatspecParsingError {
parent: Option<Parent>,
span: TextRange,
message: String,
},
#[error("`Parse::get_sources` can only be called on the last parser instance")]
DanglingParserReferences,
#[error("IO error for {path:?}: {err}")]
IOError { path: PathBuf, err: std::io::Error },
#[error("unknown error while parsing Solidity")]
UnknownError,
}