History

changed quickerror to thiserror (#415)

Sidney Douw committed 4 years ago

Commit 49fcab71 parent 13b7db54 files · +22 −23Browse files

Unified · Split

4 files
  1. Cargo.lock +1 −1
  2. git-pathspec/Cargo.toml +1 −1
  3. git-pathspec/src/parse.rs +18 −18
  4. git-pathspec/tests/pathspec.rs +2 −3
Cargo.lock+1−1
@@ -1421,7 +1421,7 @@ dependencies = [ · 1420 unmodified lines
1421 "bstr",1421 "bstr",
1422 "git-attributes",1422 "git-attributes",
1423 "git-glob",1423 "git-glob",
1424 "quick-error",1424 "thiserror",
1425]1425]
1426 1426
1427[[package]]1427[[package]]
git-pathspec/Cargo.toml+1−1
@@ -18,4 +18,4 @@ git-attributes = { version = "^0.1.0", path = "../git-attributes" } · 17 unmodified lines
18 18
19bstr = { version = "0.2.13", default-features = false, features = ["std"]}19bstr = { version = "0.2.13", default-features = false, features = ["std"]}
20bitflags = "1.3.2"20bitflags = "1.3.2"
21quick-error = "2.0.0"21thiserror = "1.0.26"
git-pathspec/src/parse.rs+18−18
@@ -1,25 +1,18 @@
1use bstr::{BString, ByteSlice};1use bstr::{BString, ByteSlice};
2use git_attributes::{parse::Iter, State};2use git_attributes::{parse::Iter, State};
3use quick_error::quick_error;
4 3
5use crate::{MagicSignature, Pattern};4use crate::{MagicSignature, Pattern};
6 5
7quick_error! {6#[derive(thiserror::Error, Debug)]
8 #[derive(Debug)]7pub enum Error {
9 pub enum Error {8 #[error("Found \"{}\", which is not a valid signature", found_signature)]
10 InvalidSignature { found_signature: BString } {9 InvalidSignature { found_signature: BString },
11 display("Found \"{}\", which is not a valid signature", found_signature)10
12 }11 #[error("Missing ')' at the end of pathspec magic in '{}'", pathspec)]
13 MissingClosingParenthesis { pathspec: BString } {12 MissingClosingParenthesis { pathspec: BString },
14 display("Missing ')' at the end of pathspec magic in '{}'", pathspec)13
15 }14 #[error("Attribute has non-ascii characters or starts with '-': {}", attribute)]
16 // TODO: Fix error messages15 InvalidAttribute { attribute: BString },
17 InvalidAttribute(err: git_attributes::parse::Error) {
18 display("{}", err)
19 from()
20 source(err)
21 }
22 }
23}16}
24 17
25impl Pattern {18impl Pattern {
@@ -97,7 +90,14 @@ fn parse_keywords(input: &[u8]) -> Result<(MagicSignature, Vec<(BString, State)> · 71 unmodified lines
97 if let Some(attrs) = s.strip_prefix(b"attr:") {90 if let Some(attrs) = s.strip_prefix(b"attr:") {
98 attributes = Iter::new(attrs.into(), 0)91 attributes = Iter::new(attrs.into(), 0)
99 .map(|res| res.map(|(attr, state)| (attr.into(), state.into())))92 .map(|res| res.map(|(attr, state)| (attr.into(), state.into())))
100 .collect::<Result<Vec<_>, _>>()?;93 .collect::<Result<Vec<_>, _>>()
94 .map_err(|e| match e {
95 git_attributes::parse::Error::AttributeName {
96 line_number: _,
97 attribute,
98 } => Error::InvalidAttribute { attribute },
99 _ => unreachable!("expecting only 'Error::AttributeName' but got {}", e),
100 })?;
101 MagicSignature::ATTR101 MagicSignature::ATTR
102 } else {102 } else {
103 return Err(Error::InvalidSignature {103 return Err(Error::InvalidSignature {
git-pathspec/tests/pathspec.rs+2−3
@@ -112,10 +112,9 @@ fn should_fail_on_whitespace_or_invalid_keywords() { · 111 unmodified lines
112 ),112 ),
113 (113 (
114 ":(attr:+someAttr)some/path",114 ":(attr:+someAttr)some/path",
115 Error::InvalidAttribute(git_attributes::parse::Error::AttributeName {115 Error::InvalidAttribute {
116 line_number: 0,
117 attribute: BString::from("+someAttr"),116 attribute: BString::from("+someAttr"),
118 }),117 },
119 ),118 ),
120 (119 (
121 ":(top",120 ":(top",