1use std::path::PathBuf;
4
5#[derive(Debug, thiserror::Error)]
7#[error("invalid data content: {message}")]
8pub struct InvalidDataContentError {
9 pub message: String,
11 #[source]
13 pub cause: Option<Box<dyn std::error::Error + Send + Sync>>,
14}
15
16impl InvalidDataContentError {
17 #[must_use]
19 pub fn new(message: impl Into<String>) -> Self {
20 Self {
21 message: message.into(),
22 cause: None,
23 }
24 }
25
26 #[must_use]
28 pub fn with_cause(mut self, cause: impl std::error::Error + Send + Sync + 'static) -> Self {
29 self.cause = Some(Box::new(cause));
30 self
31 }
32}
33
34#[derive(Debug, thiserror::Error)]
37#[non_exhaustive]
38pub enum FileSourceError {
39 #[error(transparent)]
41 InvalidDataContent(#[from] InvalidDataContentError),
42 #[error("file source path `{}` must be read before conversion", path.display())]
44 UnreadPath {
45 path: PathBuf,
47 },
48}