serialization/error.rs
1//! Contains all errors defined and used by the `serialization` crate.
2use thiserror::Error;
3
4/// Represents potential serialisation errors.
5#[derive(Error, Debug)]
6pub enum SerializationError {
7 /// Error when the selected serialisation format is unavailable.
8 ///
9 /// This is usually due to a missing feature flag.
10 #[error("The selected serialisation format is unavailable, enable feature '{}' to use.", .0)]
11 FormatUnavailable(&'static str),
12 /// Some (de)serialisation methods require I/O, if any of those I/O operations fails, this error
13 /// is returned.
14 #[error("An error occurred while writing to output: {0}")]
15 IO(#[from] std::io::Error),
16 /// An error occurred while attempting to serialize, this is mostly a wrapper for the underlying
17 /// error thrown by the serialisation libraries.
18 #[error("An error occurred while serialising: {0}")]
19 Serialize(anyhow::Error),
20 /// An error occurred while attempting to deserialize, this is mostly a wrapper for the underlying
21 /// error thrown by the serialisation libraries.
22 #[error("An error occurred while deserialising: {0}")]
23 Deserialize(anyhow::Error),
24}