better error chaining
This commit is contained in:
Generated
+50
@@ -366,6 +366,18 @@ dependencies = [
|
|||||||
"regex",
|
"regex",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "filetime"
|
||||||
|
version = "0.2.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4e884668cd0c7480504233e951174ddc3b382f7c2666e3b7310b5c4e7b0c37f9"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"redox_syscall",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.0.25"
|
version = "1.0.25"
|
||||||
@@ -436,6 +448,12 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glob"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "globset"
|
name = "globset"
|
||||||
version = "0.4.10"
|
version = "0.4.10"
|
||||||
@@ -582,12 +600,15 @@ version = "0.5.1"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
|
"flate2",
|
||||||
"git2",
|
"git2",
|
||||||
|
"glob",
|
||||||
"open",
|
"open",
|
||||||
"pulldown-cmark",
|
"pulldown-cmark",
|
||||||
"rayon",
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
"syntect",
|
"syntect",
|
||||||
|
"tar",
|
||||||
"tera",
|
"tera",
|
||||||
"toml",
|
"toml",
|
||||||
]
|
]
|
||||||
@@ -1053,6 +1074,15 @@ dependencies = [
|
|||||||
"num_cpus",
|
"num_cpus",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_syscall"
|
||||||
|
version = "0.2.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.7.0"
|
version = "1.7.0"
|
||||||
@@ -1215,6 +1245,17 @@ dependencies = [
|
|||||||
"yaml-rust",
|
"yaml-rust",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tar"
|
||||||
|
version = "0.4.38"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6"
|
||||||
|
dependencies = [
|
||||||
|
"filetime",
|
||||||
|
"libc",
|
||||||
|
"xattr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tera"
|
name = "tera"
|
||||||
version = "1.17.1"
|
version = "1.17.1"
|
||||||
@@ -1632,6 +1673,15 @@ version = "0.42.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
|
checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "xattr"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6d1526bbe5aaeb5eb06885f4d987bcdfa5e23187055de9b83fe00156a821fabc"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xml-rs"
|
name = "xml-rs"
|
||||||
version = "0.8.4"
|
version = "0.8.4"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ highlight = ["syntect/default-fancy"]
|
|||||||
chrono = { version = "0.4.23", features=["clock"] }
|
chrono = { version = "0.4.23", features=["clock"] }
|
||||||
clap = { version="4.0.32", features=["derive"] }
|
clap = { version="4.0.32", features=["derive"] }
|
||||||
git2 = "0.15.0"
|
git2 = "0.15.0"
|
||||||
|
glob = "0.3.1"
|
||||||
open = "3.2.0"
|
open = "3.2.0"
|
||||||
pulldown-cmark = { version = "0.9.2", optional = true }
|
pulldown-cmark = { version = "0.9.2", optional = true }
|
||||||
rayon = "1.6.1"
|
rayon = "1.6.1"
|
||||||
@@ -32,3 +33,7 @@ toml = "0.5.10"
|
|||||||
# For SSH passphrase support:
|
# For SSH passphrase support:
|
||||||
#pinentry = "0.5.0"
|
#pinentry = "0.5.0"
|
||||||
#secrecy = "0.8.0"
|
#secrecy = "0.8.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
flate2 = "1.0.25"
|
||||||
|
tar = "0.4.38"
|
||||||
|
|||||||
+12
-4
@@ -20,6 +20,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with Itsy-Gitsy. If not, see <http://www.gnu.org/licenses/>.
|
* along with Itsy-Gitsy. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
use glob::glob;
|
||||||
|
use std::error::Error as StdError;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::atomic::AtomicUsize;
|
use std::sync::atomic::AtomicUsize;
|
||||||
@@ -83,6 +85,7 @@ pub enum GitsyErrorKind {
|
|||||||
Settings,
|
Settings,
|
||||||
Template,
|
Template,
|
||||||
Git,
|
Git,
|
||||||
|
Filesystem,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@@ -126,9 +129,14 @@ impl std::fmt::Display for GitsyError {
|
|||||||
GitsyErrorKind::Git => write!(f, "gitsy error (git)")?,
|
GitsyErrorKind::Git => write!(f, "gitsy error (git)")?,
|
||||||
GitsyErrorKind::Settings => write!(f, "gitsy error (settings)")?,
|
GitsyErrorKind::Settings => write!(f, "gitsy error (settings)")?,
|
||||||
GitsyErrorKind::Template => write!(f, "gitsy error (template)")?,
|
GitsyErrorKind::Template => write!(f, "gitsy error (template)")?,
|
||||||
_ => write!(f, "gitsy error (unknown)")?,
|
GitsyErrorKind::Filesystem => write!(f, "gitsy error (filesystem)")?,
|
||||||
|
GitsyErrorKind::Unknown => write!(f, "gitsy error (unknown)")?,
|
||||||
}
|
}
|
||||||
write!(f, ": {}", self.msg.as_deref().unwrap_or_default())
|
write!(f, ": {}", self.msg.as_deref().unwrap_or_default())?;
|
||||||
|
if let Some(src) = &self.source {
|
||||||
|
write!(f, " ({})", src)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl std::fmt::Debug for GitsyError {
|
impl std::fmt::Debug for GitsyError {
|
||||||
@@ -137,8 +145,8 @@ impl std::fmt::Debug for GitsyError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl std::error::Error for GitsyError {
|
impl std::error::Error for GitsyError {
|
||||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
fn source(&self) -> Option<&(dyn StdError + 'static)> {
|
||||||
self.source.as_deref()
|
self.source.as_ref().map(|c| &**c as &(dyn StdError + 'static))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<git2::Error> for GitsyError {
|
impl From<git2::Error> for GitsyError {
|
||||||
|
|||||||
Reference in New Issue
Block a user