polyhorn_cli/spec/
error.rs

1/// Represents an error that is encountered while loading and parsing a
2/// specification from a `Polyhorn.toml` file.
3#[derive(Debug)]
4pub enum Error {
5    /// Contains an error that is encountered while loading the contents of the
6    /// `Polyhorn.toml` file from disk.
7    IO(std::io::Error),
8
9    /// Contains an error that is encountered while parsing the `Polyhorn.toml`
10    /// file in memory.
11    TOML(toml::de::Error),
12}
13
14impl From<std::io::Error> for Error {
15    fn from(value: std::io::Error) -> Self {
16        Error::IO(value)
17    }
18}
19
20impl From<toml::de::Error> for Error {
21    fn from(value: toml::de::Error) -> Self {
22        Error::TOML(value)
23    }
24}
25
26impl std::fmt::Display for Error {
27    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28        std::fmt::Debug::fmt(self, f)
29    }
30}
31
32impl std::error::Error for Error {}