History

use thiserror instead of quickerror

Sebastian Thiel committed 4 years ago

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

Showing the changes to git-traverse/src/commit.rs (1 of 4 files). Show all

Unified · Split

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 }

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