| 1 | //! Error types for `last30days-core`. |
| 2 | |
| 3 | use std::path::PathBuf; |
| 4 | |
| 5 | use thiserror::Error; |
| 6 | |
| 7 | /// Errors returned by fallible operations in `last30days-core`. |
| 8 | #[derive(Debug, Error)] |
| 9 | #[non_exhaustive] |
| 10 | pub enum CoreError { |
| 11 | /// A threshold or numeric parameter was outside its valid range. |
| 12 | #[error("invalid threshold {value}: expected a finite value in [0.0, 1.0]")] |
| 13 | InvalidThreshold { |
| 14 | /// The rejected threshold value. |
| 15 | value: f64, |
| 16 | }, |
| 17 | |
| 18 | /// An n-gram size was zero. |
| 19 | #[error("invalid n-gram size: must be at least 1")] |
| 20 | InvalidNgramSize, |
| 21 | |
| 22 | /// An ISO date string could not be parsed. |
| 23 | #[error("invalid ISO date `{input}`: expected YYYY-MM-DD")] |
| 24 | InvalidDate { |
| 25 | /// The malformed date string. |
| 26 | input: String, |
| 27 | }, |
| 28 | |
| 29 | /// A saved Markdown file had no extractable title. |
| 30 | #[error("no markdown title found")] |
| 31 | MissingMarkdownTitle, |
| 32 | |
| 33 | /// A saved Markdown file had an empty title after inline cleanup. |
| 34 | #[error("empty markdown title")] |
| 35 | EmptyMarkdownTitle, |
| 36 | |
| 37 | /// Reading a file from disk failed. |
| 38 | #[error("failed to read `{path}`")] |
| 39 | ReadFile { |
| 40 | /// Path that failed to read. |
| 41 | path: PathBuf, |
| 42 | /// Underlying I/O error. |
| 43 | #[source] |
| 44 | source: std::io::Error, |
| 45 | }, |
| 46 | } |
| 47 | |
| 48 | const _: () = { |
| 49 | const fn assert_send_sync<T: Send + Sync + 'static>() {} |
| 50 | assert_send_sync::<CoreError>(); |
| 51 | }; |
| 52 |