Improve fmt::Display impl for all Error types (#781)

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-02-10 14:01:22 +11:00 committed by GitHub
parent 9d9b72c768
commit d9dd611b9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 17 deletions

View file

@ -27,17 +27,17 @@ mod utils;
#[derive(Debug, ThisError)] #[derive(Debug, ThisError)]
pub enum DownloadError { pub enum DownloadError {
#[error(transparent)] #[error("Failed to extract zipfile: {0}")]
Unzip(#[from] ZipError), Unzip(#[from] ZipError),
#[error(transparent)] #[error("Failed to download from remote: {0}")]
Remote(#[from] RemoteError), Remote(#[from] RemoteError),
/// A generic I/O error. /// A generic I/O error.
/// ///
/// - Code: `binstall::io` /// - Code: `binstall::io`
/// - Exit: 74 /// - Exit: 74
#[error(transparent)] #[error("I/O Error: {0}")]
Io(io::Error), Io(io::Error),
} }

View file

@ -28,7 +28,7 @@ const DEFAULT_MIN_TLS: tls::Version = tls::Version::TLS_1_2;
#[derive(Debug, ThisError)] #[derive(Debug, ThisError)]
pub enum Error { pub enum Error {
#[error(transparent)] #[error("Reqwest error: {0}")]
Reqwest(#[from] reqwest::Error), Reqwest(#[from] reqwest::Error),
#[error(transparent)] #[error(transparent)]

View file

@ -31,10 +31,10 @@ const BUFFER_SIZE: usize = 4096 * 5;
#[derive(Debug, Diagnostic, Error)] #[derive(Debug, Diagnostic, Error)]
#[non_exhaustive] #[non_exhaustive]
pub enum Error { pub enum Error {
#[error(transparent)] #[error("I/O Error: {0}")]
Io(#[from] io::Error), Io(#[from] io::Error),
#[error(transparent)] #[error("Failed to parse json: {0}")]
SerdeJsonParse(#[from] serde_json::Error), SerdeJsonParse(#[from] serde_json::Error),
} }

View file

@ -181,13 +181,13 @@ impl CratesToml<'_> {
#[derive(Debug, Diagnostic, Error)] #[derive(Debug, Diagnostic, Error)]
#[non_exhaustive] #[non_exhaustive]
pub enum CratesTomlParseError { pub enum CratesTomlParseError {
#[error(transparent)] #[error("I/O Error: {0}")]
Io(#[from] io::Error), Io(#[from] io::Error),
#[error(transparent)] #[error("Failed to deserialize toml: {0}")]
TomlParse(Box<toml_edit::de::Error>), TomlParse(Box<toml_edit::de::Error>),
#[error(transparent)] #[error("Failed to serialie toml: {0}")]
TomlWrite(Box<toml_edit::ser::Error>), TomlWrite(Box<toml_edit::ser::Error>),
#[error(transparent)] #[error(transparent)]

View file

@ -98,10 +98,10 @@ impl FromStr for CrateVersionSource {
#[derive(Debug, Diagnostic, Error)] #[derive(Debug, Diagnostic, Error)]
#[non_exhaustive] #[non_exhaustive]
pub enum CvsParseError { pub enum CvsParseError {
#[error(transparent)] #[error("Failed to parse url in cvs: {0}")]
UrlParse(#[from] url::ParseError), UrlParse(#[from] url::ParseError),
#[error(transparent)] #[error("Failed to parse version in cvs: {0}")]
VersionParse(#[from] semver::Error), VersionParse(#[from] semver::Error),
#[error("unknown source type {kind}+{arg}")] #[error("unknown source type {kind}+{arg}")]

View file

@ -79,7 +79,7 @@ pub enum BinstallError {
/// ///
/// - Code: `binstall::url_parse` /// - Code: `binstall::url_parse`
/// - Exit: 65 /// - Exit: 65
#[error(transparent)] #[error("Failed to parse url: {0}")]
#[diagnostic(severity(error), code(binstall::url_parse))] #[diagnostic(severity(error), code(binstall::url_parse))]
UrlParse(#[from] url::ParseError), UrlParse(#[from] url::ParseError),
@ -87,7 +87,7 @@ pub enum BinstallError {
/// ///
/// - Code: `binstall::unzip` /// - Code: `binstall::unzip`
/// - Exit: 66 /// - Exit: 66
#[error(transparent)] #[error("Failed to extract zipfile: {0}")]
#[diagnostic(severity(error), code(binstall::unzip))] #[diagnostic(severity(error), code(binstall::unzip))]
Unzip(#[from] ZipError), Unzip(#[from] ZipError),
@ -95,7 +95,7 @@ pub enum BinstallError {
/// ///
/// - Code: `binstall::template` /// - Code: `binstall::template`
/// - Exit: 67 /// - Exit: 67
#[error(transparent)] #[error("Failed to render template: {0}")]
#[diagnostic(severity(error), code(binstall::template))] #[diagnostic(severity(error), code(binstall::template))]
Template(Box<TinyTemplateError>), Template(Box<TinyTemplateError>),
@ -105,7 +105,7 @@ pub enum BinstallError {
/// ///
/// - Code: `binstall::reqwest` /// - Code: `binstall::reqwest`
/// - Exit: 68 /// - Exit: 68
#[error(transparent)] #[error("Reqwest error: {0}")]
#[diagnostic(severity(error), code(binstall::reqwest))] #[diagnostic(severity(error), code(binstall::reqwest))]
Reqwest(#[from] ReqwestError), Reqwest(#[from] ReqwestError),
@ -137,7 +137,7 @@ pub enum BinstallError {
/// ///
/// - Code: `binstall::io` /// - Code: `binstall::io`
/// - Exit: 74 /// - Exit: 74
#[error(transparent)] #[error("I/O Error: {0}")]
#[diagnostic(severity(error), code(binstall::io))] #[diagnostic(severity(error), code(binstall::io))]
Io(io::Error), Io(io::Error),
@ -171,7 +171,7 @@ pub enum BinstallError {
/// ///
/// - Code: `binstall::cargo_manifest` /// - Code: `binstall::cargo_manifest`
/// - Exit: 78 /// - Exit: 78
#[error(transparent)] #[error("Failed to parse cargo manifest: {0}")]
#[diagnostic( #[diagnostic(
severity(error), severity(error),
code(binstall::cargo_manifest), code(binstall::cargo_manifest),