@@ -2,11 +2,11 @@ use aligned_sdk::core::types::VerificationData;
22
33#[ derive( Debug ) ]
44pub enum GetBatchProofsError {
5- Fetching ,
6- Deserialization ,
7- EmptyBody ,
8- StatusFailed ,
9- ReqwestClientFailed ,
5+ FetchingS3Batch ( String ) ,
6+ Deserialization ( String ) ,
7+ EmptyBody ( String ) ,
8+ StatusFailed ( String ) ,
9+ ReqwestClientFailed ( ( u16 , String ) ) ,
1010}
1111
1212// needed to make S3 bucket work
@@ -18,25 +18,28 @@ pub async fn get_aligned_batch_from_s3(
1818 let client = reqwest:: Client :: builder ( )
1919 . user_agent ( DEFAULT_USER_AGENT )
2020 . build ( )
21- . map_err ( |_ | GetBatchProofsError :: ReqwestClientFailed ) ?;
21+ . map_err ( |e | GetBatchProofsError :: ReqwestClientFailed ( e . to_string ( ) ) ) ?;
2222
2323 let response = client
2424 . get ( url)
2525 . send ( )
2626 . await
27- . map_err ( |_ | GetBatchProofsError :: Fetching ) ?;
27+ . map_err ( |e | GetBatchProofsError :: FetchingS3Batch ( e . to_string ( ) ) ) ?;
2828 if !response. status ( ) . is_success ( ) {
29- return Err ( GetBatchProofsError :: StatusFailed ) ;
29+ return Err ( GetBatchProofsError :: StatusFailed ( (
30+ response. status ( ) . as_u16 ( ) ,
31+ response. status ( ) . canonical_reason ( ) ,
32+ ) ) ) ;
3033 }
3134
3235 let bytes = response
3336 . bytes ( )
3437 . await
35- . map_err ( |_ | GetBatchProofsError :: EmptyBody ) ?;
38+ . map_err ( |e | GetBatchProofsError :: EmptyBody ( e . to_string ( ) ) ) ?;
3639 let bytes: & [ u8 ] = bytes. iter ( ) . as_slice ( ) ;
3740
38- let data: Vec < VerificationData > =
39- ciborium :: from_reader ( bytes ) . map_err ( |_ | GetBatchProofsError :: Deserialization ) ?;
41+ let data: Vec < VerificationData > = ciborium :: from_reader ( bytes )
42+ . map_err ( |e | GetBatchProofsError :: Deserialization ( e . to_string ( ) ) ) ?;
4043
4144 Ok ( data)
4245}
0 commit comments