rust_releases_rust_changelog/
errors.rs

1use rust_releases_core::Channel;
2
3/// A result type which binds the `RustChangelogError` to the error type.
4pub type RustChangelogResult<T> = Result<T, RustChangelogError>;
5
6/// Top level failure cases for rust-releases-rust-changelog source crate
7#[derive(Debug, thiserror::Error)]
8#[non_exhaustive]
9pub enum RustChangelogError {
10    /// Returned in case a `Channel` is not available for the `Source`
11    #[error("Channel {0} is not available for the 'RustChangelog' source type")]
12    ChannelNotAvailable(Channel),
13
14    /// Returned in case of of `chrono` parse errors
15    #[error("Unable to parse release date in a release entry '{0}': {1}")]
16    TimeParseError(String, time::error::Parse),
17
18    /// Returned in a case a release entry does not contain a recognizable release date
19    #[error("Unable to find a valid release date in a release entry")]
20    NoDateInChangelogItem,
21
22    /// Returned in a case a release entry does not contain a recognizable release version
23    #[error("Unable to find a valid version in a release entry")]
24    NoVersionInChangelogItem,
25
26    /// Returned in case the base cache dir could not be found
27    #[error(transparent)]
28    BaseCacheDir(#[from] rust_releases_io::BaseCacheDirError),
29
30    /// Returned in case a cached client error is returned
31    #[error(transparent)]
32    CachedClient(#[from] rust_releases_io::CachedClientError),
33
34    /// Returned in case a staleness check error is returned
35    #[error(transparent)]
36    IsStale(#[from] rust_releases_io::IsStaleError),
37
38    /// Returned in case of semver error on the hot path
39    #[error("{0}, input was: {1}")]
40    SemverError(rust_releases_core::semver::Error, String),
41
42    /// Returned in case a input resource cannot be parsed as UTF-8
43    #[error(transparent)]
44    UnrecognizedText(#[from] std::str::Utf8Error),
45}