@@ -12,7 +12,6 @@ use git_repository::{
12
12
odb:: { loose, pack, Write } ,
13
13
Progress ,
14
14
} ;
15
- use quick_error:: quick_error;
16
15
17
16
#[ derive( Eq , PartialEq , Debug ) ]
18
17
pub enum SafetyCheck {
@@ -69,39 +68,30 @@ impl From<SafetyCheck> for pack::index::traverse::SafetyCheck {
69
68
}
70
69
}
71
70
72
- quick_error ! {
73
- #[ derive( Debug ) ]
74
- enum Error {
75
- Io ( err: std:: io:: Error ) {
76
- display( "An IO error occurred while writing an object" )
77
- source( err)
78
- from( )
79
- }
80
- OdbWrite ( err: loose:: write:: Error ) {
81
- display( "An object could not be written to the database" )
82
- source( err)
83
- from( )
84
- }
85
- Write ( err: Box <dyn std:: error:: Error + Send + Sync >, kind: object:: Kind , id: ObjectId ) {
86
- display( "Failed to write {} object {}" , kind, id)
87
- source( & * * err)
88
- }
89
- Verify ( err: objs:: data:: verify:: Error ) {
90
- display( "Object didn't verify after right after writing it" )
91
- source( err)
92
- from( )
93
- }
94
- ObjectEncodeMismatch ( kind: object:: Kind , actual: ObjectId , expected: ObjectId ) {
95
- display( "{} object {} wasn't re-encoded without change - new hash is {}" , kind, expected, actual)
96
- }
97
- WrittenFileMissing ( id: ObjectId ) {
98
- display( "The recently written file for loose object {} could not be found" , id)
99
- }
100
- WrittenFileCorrupt ( err: loose:: find:: Error , id: ObjectId ) {
101
- display( "The recently written file for loose object {} cold not be read" , id)
102
- source( err)
103
- }
104
- }
71
+ #[ derive( Debug , thiserror:: Error ) ]
72
+ enum Error {
73
+ #[ error( "An IO error occurred while writing an object" ) ]
74
+ Io ( #[ from] std:: io:: Error ) ,
75
+ #[ error( "An object could not be written to the database" ) ]
76
+ OdbWrite ( #[ from] loose:: write:: Error ) ,
77
+ #[ error( "Failed to write {kind} object {id}" ) ]
78
+ Write {
79
+ source : Box < dyn std:: error:: Error + Send + Sync > ,
80
+ kind : object:: Kind ,
81
+ id : ObjectId ,
82
+ } ,
83
+ #[ error( "Object didn't verify after right after writing it" ) ]
84
+ Verify ( #[ from] objs:: data:: verify:: Error ) ,
85
+ #[ error( "{kind} object {expected} wasn't re-encoded without change - new hash is {actual}" ) ]
86
+ ObjectEncodeMismatch {
87
+ kind : object:: Kind ,
88
+ actual : ObjectId ,
89
+ expected : ObjectId ,
90
+ } ,
91
+ #[ error( "The recently written file for loose object {id} could not be found" ) ]
92
+ WrittenFileMissing { id : ObjectId } ,
93
+ #[ error( "The recently written file for loose object {id} cold not be read" ) ]
94
+ WrittenFileCorrupt { source : loose:: find:: Error , id : ObjectId } ,
105
95
}
106
96
107
97
#[ allow( clippy:: large_enum_variant) ]
@@ -206,11 +196,10 @@ pub fn pack_or_pack_index(
206
196
let mut read_buf = Vec :: new ( ) ;
207
197
move |object_kind, buf, index_entry, progress| {
208
198
let written_id = out. write_buf ( object_kind, buf) . map_err ( |err| {
209
- Error :: Write (
210
- Box :: new ( err) as Box < dyn std:: error:: Error + Send + Sync > ,
211
- object_kind,
212
- index_entry. oid ,
213
- )
199
+ Error :: Write { source : Box :: new ( err) as Box < dyn std:: error:: Error + Send + Sync > ,
200
+ kind : object_kind,
201
+ id : index_entry. oid ,
202
+ }
214
203
} ) ?;
215
204
if written_id != index_entry. oid {
216
205
if let object:: Kind :: Tree = object_kind {
@@ -219,14 +208,14 @@ pub fn pack_or_pack_index(
219
208
index_entry. oid, written_id
220
209
) ) ;
221
210
} else {
222
- return Err ( Error :: ObjectEncodeMismatch ( object_kind, index_entry. oid , written_id) ) ;
211
+ return Err ( Error :: ObjectEncodeMismatch { kind : object_kind, actual : index_entry. oid , expected : written_id} ) ;
223
212
}
224
213
}
225
214
if let Some ( verifier) = loose_odb. as_ref ( ) {
226
215
let obj = verifier
227
216
. try_find ( written_id, & mut read_buf)
228
- . map_err ( |err| Error :: WrittenFileCorrupt ( err, written_id) ) ?
229
- . ok_or ( Error :: WrittenFileMissing ( written_id) ) ?;
217
+ . map_err ( |err| Error :: WrittenFileCorrupt { source : err, id : written_id} ) ?
218
+ . ok_or ( Error :: WrittenFileMissing { id : written_id} ) ?;
230
219
obj. verify_checksum ( written_id) ?;
231
220
}
232
221
Ok ( ( ) )
0 commit comments