mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-20 04:13:07 +02:00
Don't expose third-party errors in public API.
This commit is contained in:
parent
f56296ea93
commit
2f7196dbfc
1 changed files with 17 additions and 12 deletions
|
@ -19,20 +19,25 @@ pub enum Error {
|
||||||
/// A usage error
|
/// A usage error
|
||||||
#[error("User Error: {0}")]
|
#[error("User Error: {0}")]
|
||||||
Usage(String),
|
Usage(String),
|
||||||
|
/// A general error.
|
||||||
/// Error conversions.
|
|
||||||
#[error(transparent)]
|
|
||||||
Http(#[from] ureq::Error),
|
|
||||||
#[error(transparent)]
|
|
||||||
Io(#[from] io::Error),
|
|
||||||
#[error(transparent)]
|
|
||||||
Json(#[from] serde_json::Error),
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
#[error("Third Party Sqlite Error")]
|
|
||||||
Rusqlite(#[from] rusqlite::Error),
|
|
||||||
#[error(transparent)]
|
|
||||||
Sqlite(#[from] crate::storage::sqlite::SqliteError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert private and third party errors into Error::Other.
|
||||||
|
macro_rules! convert_error {
|
||||||
|
( $error:ty ) => {
|
||||||
|
impl From<$error> for Error {
|
||||||
|
fn from(err: $error) -> Self {
|
||||||
|
Self::Other(err.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
convert_error!(ureq::Error);
|
||||||
|
convert_error!(io::Error);
|
||||||
|
convert_error!(serde_json::Error);
|
||||||
|
convert_error!(rusqlite::Error);
|
||||||
|
convert_error!(crate::storage::sqlite::SqliteError);
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue