star_catalog/
error.rs

1//a Imports
2use thiserror::Error;
3
4//tp Error
5/// Errors that can be generated by a [crate::Catalog]
6#[derive(Debug, Error)]
7pub enum Error {
8    /// Std IO error
9    #[error("{0}: {1}")]
10    IO(String, #[source] std::io::Error),
11
12    /// Json parsing error
13    #[error("{0}")]
14    Json(#[from] serde_json::Error),
15
16    /// Unknown catalog
17    #[error("Unknown builtin catalog")]
18    UnknownCatalog,
19
20    /// Unknown catalog extension
21    #[error("Unknown builtin catalog extension")]
22    UnknownCatalogExtension,
23
24    /// Failure to find an id within the catalog of stars
25    #[error("Failed to find Id {0} in the catalog")]
26    FailedToFindId(usize),
27
28    /// Failure to find a star name in the name-to-id map of a catalog
29    /// of stars
30    #[error("Failed to find star name in the catalog")]
31    FailedToFindName,
32
33    #[cfg(feature = "csv")]
34    /// Failed to read a CSV file for a catalog
35    #[error("Failed to read CSV file: {0}")]
36    CsvError(#[from] csv::Error),
37
38    #[cfg(feature = "postcard")]
39    /// Failed to read a CSV file for a catalog
40    #[error("Failed to read Postcard file: {0}")]
41    Postcard(#[from] postcard::Error),
42}
43
44impl std::convert::From<(std::io::Error, String)> for Error {
45    fn from((e, s): (std::io::Error, String)) -> Error {
46        Error::IO(s, e)
47    }
48}