History

use thiserror instead of quickerror

Sebastian Thiel committed 4 years ago

Commit 2ed0ee21 parent 0661d484 files · +36 −39Browse files

Unified · Split

4 files
  1. Cargo.lock +1 −1
  2. git-traverse/Cargo.toml +1 −1
  3. git-traverse/src/commit.rs +24 −19
  4. git-traverse/src/tree/breadthfirst.rs +10 −18
Cargo.lock+1−1
@@ -1661,7 +1661,7 @@ dependencies = [ · 1660 unmodified lines
16611661 "git-odb",
16621662 "git-testtools",
16631663 "hash_hasher",
1664− "quick-error",
1664+ "thiserror",
16651665 ]
16661666
16671667 [[package]]
git-traverse/Cargo.toml+1−1
@@ -14,7 +14,7 @@ doctest = false · 13 unmodified lines
1414 [dependencies]
1515 git-hash = { version = "^0.9.8", path = "../git-hash" }
1616 git-object = { version = "^0.20.2", path = "../git-object" }
17−quick-error = "2.0.0"
17+thiserror = "1.0.32"
1818 hash_hasher = "2.0.3"
1919
2020 [dev-dependencies]
git-traverse/src/commit.rs+24−19
@@ -50,25 +50,20 @@ pub mod ancestors { · 49 unmodified lines
5050
5151 use git_hash::{oid, ObjectId};
5252 use git_object::CommitRefIter;
53− use quick_error::quick_error;
5453
5554 use crate::commit::{Ancestors, Parents, Sorting};
5655
57− quick_error! {
58− /// The error is part of the item returned by the [Ancestors] iterator.
59− #[derive(Debug)]
60− #[allow(missing_docs)]
61− pub enum Error {
62− FindExisting{oid: ObjectId, err: Box<dyn std::error::Error + Send + Sync + 'static> } {
63− display("The commit {} could not be found", oid)
64− source(&**err)
65− }
66− ObjectDecode(err: git_object::decode::Error) {
67− display("An object could not be decoded")
68− source(err)
69− from()
70− }
71− }
56+ /// The error is part of the item returned by the [Ancestors] iterator.
57+ #[derive(Debug, thiserror::Error)]
58+ #[allow(missing_docs)]
59+ pub enum Error {
60+ #[error("The commit {oid} could not be found")]
61+ FindExisting {
62+ oid: ObjectId,
63+ source: Box<dyn std::error::Error + Send + Sync + 'static>,
64+ },
65+ #[error(transparent)]
66+ ObjectDecode(#[from] git_object::decode::Error),
7267 }
7368
7469 type TimeInSeconds = u32;
@@ -112,7 +107,7 @@ pub mod ancestors { · 37 unmodified lines
112107 for (commit_id, commit_time) in state.next.iter_mut() {
113108 let commit_iter = (self.find)(commit_id, &mut state.buf).map_err(|err| Error::FindExisting {
114109 oid: *commit_id,
115− err: err.into(),
110+ source: err.into(),
116111 })?;
117112 *commit_time = commit_iter.committer()?.time.seconds_since_unix_epoch;
118113 }
@@ -266,7 +261,12 @@ pub mod ancestors { · 147 unmodified lines
266261 }
267262 }
268263 }
269− Err(err) => return Some(Err(Error::FindExisting { oid, err: err.into() })),
264+ Err(err) => {
265+ return Some(Err(Error::FindExisting {
266+ oid,
267+ source: err.into(),
268+ }))
269+ }
270270 }
271271 Some(Ok(oid))
272272 }
@@ -301,7 +301,12 @@ pub mod ancestors { · 28 unmodified lines
301301 }
302302 }
303303 }
304− Err(err) => return Some(Err(Error::FindExisting { oid, err: err.into() })),
304+ Err(err) => {
305+ return Some(Err(Error::FindExisting {
306+ oid,
307+ source: err.into(),
308+ }))
309+ }
305310 }
306311 Some(Ok(oid))
307312 }
git-traverse/src/tree/breadthfirst.rs+10−18
@@ -1,25 +1,17 @@
11 use std::collections::VecDeque;
22
33 use git_hash::ObjectId;
4−use quick_error::quick_error;
54
6−quick_error! {
7− /// The error is part of the item returned by the [`traverse()`] function.
8− #[derive(Debug)]
9− #[allow(missing_docs)]
10− pub enum Error {
11− NotFound{oid: ObjectId} {
12− display("The tree {} could not be found", oid)
13− }
14− Cancelled {
15− display("The delegate cancelled the operation")
16− }
17− ObjectDecode(err: git_object::decode::Error) {
18− display("An object could not be decoded")
19− source(err)
20− from()
21− }
22− }
5+/// The error is part of the item returned by the [`traverse()`] function.
6+#[derive(Debug, thiserror::Error)]
7+#[allow(missing_docs)]
8+pub enum Error {
9+ #[error("The tree {oid} could not be found")]
10+ NotFound { oid: ObjectId },
11+ #[error("The delegate cancelled the operation")]
12+ Cancelled,
13+ #[error(transparent)]
14+ ObjectDecode(#[from] git_object::decode::Error),
2315 }
2416
2517 /// The state used and potentially shared by multiple tree traversals.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t