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
1661 "git-odb",1661 "git-odb",
1662 "git-testtools",1662 "git-testtools",
1663 "hash_hasher",1663 "hash_hasher",
1664 "quick-error",1664 "thiserror",
1665]1665]
1666 1666
1667[[package]]1667[[package]]
git-traverse/Cargo.toml+1−1
@@ -14,7 +14,7 @@ doctest = false · 13 unmodified lines
14[dependencies]14[dependencies]
15git-hash = { version = "^0.9.8", path = "../git-hash" }15git-hash = { version = "^0.9.8", path = "../git-hash" }
16git-object = { version = "^0.20.2", path = "../git-object" }16git-object = { version = "^0.20.2", path = "../git-object" }
17quick-error = "2.0.0"17thiserror = "1.0.32"
18hash_hasher = "2.0.3"18hash_hasher = "2.0.3"
19 19
20[dev-dependencies]20[dev-dependencies]
git-traverse/src/commit.rs+24−19
@@ -50,25 +50,20 @@ pub mod ancestors { · 49 unmodified lines
50 50
51 use git_hash::{oid, ObjectId};51 use git_hash::{oid, ObjectId};
52 use git_object::CommitRefIter;52 use git_object::CommitRefIter;
53 use quick_error::quick_error;
54 53
55 use crate::commit::{Ancestors, Parents, Sorting};54 use crate::commit::{Ancestors, Parents, Sorting};
56 55
57 quick_error! {56 /// The error is part of the item returned by the [Ancestors] iterator.
58 /// The error is part of the item returned by the [Ancestors] iterator.57 #[derive(Debug, thiserror::Error)]
59 #[derive(Debug)]58 #[allow(missing_docs)]
60 #[allow(missing_docs)]59 pub enum Error {
61 pub enum Error {60 #[error("The commit {oid} could not be found")]
62 FindExisting{oid: ObjectId, err: Box<dyn std::error::Error + Send + Sync + 'static> } {61 FindExisting {
63 display("The commit {} could not be found", oid)62 oid: ObjectId,
64 source(&**err)63 source: Box<dyn std::error::Error + Send + Sync + 'static>,
65 }64 },
66 ObjectDecode(err: git_object::decode::Error) {65 #[error(transparent)]
67 display("An object could not be decoded")66 ObjectDecode(#[from] git_object::decode::Error),
68 source(err)
69 from()
70 }
71 }
72 }67 }
73 68
74 type TimeInSeconds = u32;69 type TimeInSeconds = u32;
@@ -112,7 +107,7 @@ pub mod ancestors { · 37 unmodified lines
112 for (commit_id, commit_time) in state.next.iter_mut() {107 for (commit_id, commit_time) in state.next.iter_mut() {
113 let commit_iter = (self.find)(commit_id, &mut state.buf).map_err(|err| Error::FindExisting {108 let commit_iter = (self.find)(commit_id, &mut state.buf).map_err(|err| Error::FindExisting {
114 oid: *commit_id,109 oid: *commit_id,
115 err: err.into(),110 source: err.into(),
116 })?;111 })?;
117 *commit_time = commit_iter.committer()?.time.seconds_since_unix_epoch;112 *commit_time = commit_iter.committer()?.time.seconds_since_unix_epoch;
118 }113 }
@@ -266,7 +261,12 @@ pub mod ancestors { · 147 unmodified lines
266 }261 }
267 }262 }
268 }263 }
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 }
270 }270 }
271 Some(Ok(oid))271 Some(Ok(oid))
272 }272 }
@@ -301,7 +301,12 @@ pub mod ancestors { · 28 unmodified lines
301 }301 }
302 }302 }
303 }303 }
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 }
305 }310 }
306 Some(Ok(oid))311 Some(Ok(oid))
307 }312 }
git-traverse/src/tree/breadthfirst.rs+10−18
@@ -1,25 +1,17 @@
1use std::collections::VecDeque;1use std::collections::VecDeque;
2 2
3use git_hash::ObjectId;3use git_hash::ObjectId;
4use quick_error::quick_error;
5 4
6quick_error! {5/// The error is part of the item returned by the [`traverse()`] function.
7 /// The error is part of the item returned by the [`traverse()`] function.6#[derive(Debug, thiserror::Error)]
8 #[derive(Debug)]7#[allow(missing_docs)]
9 #[allow(missing_docs)]8pub enum Error {
10 pub enum Error {9 #[error("The tree {oid} could not be found")]
11 NotFound{oid: ObjectId} {10 NotFound { oid: ObjectId },
12 display("The tree {} could not be found", oid)11 #[error("The delegate cancelled the operation")]
13 }12 Cancelled,
14 Cancelled {13 #[error(transparent)]
15 display("The delegate cancelled the operation")14 ObjectDecode(#[from] git_object::decode::Error),
16 }
17 ObjectDecode(err: git_object::decode::Error) {
18 display("An object could not be decoded")
19 source(err)
20 from()
21 }
22 }
23}15}
24 16
25/// The state used and potentially shared by multiple tree traversals.17/// 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