@@ -133,21 +133,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
133
133
if mnemonic && file_path. is_some ( ) {
134
134
panic ! ( "Please use only one of '--file_path' and '--mnemonic'." )
135
135
}
136
- let filename: String ;
137
- if !mnemonic {
136
+ let filename = if !mnemonic {
138
137
// Read doc state from file path
139
138
let doc_state = if let Some ( file_path) = file_path {
140
139
Some ( serde_json:: from_reader ( File :: open ( file_path) ?) ?)
141
140
} else {
142
141
None
143
142
} ;
144
- filename = create_operation ( doc_state, verbose) ?;
143
+ create_operation ( doc_state, verbose) ?
145
144
} else {
146
145
let mut mnemonic = String :: new ( ) ;
147
146
println ! ( "Enter a mnemonic:" ) ;
148
147
std:: io:: stdin ( ) . read_line ( & mut mnemonic) . unwrap ( ) ;
149
- filename = create_operation_mnemonic ( & mnemonic, None ) ?;
150
- }
148
+ create_operation_mnemonic ( & mnemonic, None ) ?
149
+ } ;
151
150
println ! (
152
151
"Created new DID: {}" ,
153
152
filename
@@ -264,7 +263,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
264
263
// Handle result
265
264
match verify_result {
266
265
Err ( cred_err) => {
267
- handle_credential_error ( & cred_err) ;
266
+ handle_credential_error ( cred_err) ? ;
268
267
}
269
268
Ok ( _) => {
270
269
println ! ( "Proof.... ✅" ) ;
@@ -357,10 +356,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
357
356
. await ;
358
357
// Handle result
359
358
match verify_result {
360
- ref _e @ Err ( DataCredentialError :: CredentialError ( ref cred_err) ) => {
361
- handle_credential_error ( cred_err) ;
359
+ Err ( DataCredentialError :: CredentialError ( cred_err) ) => {
360
+ handle_credential_error ( cred_err) ? ;
362
361
}
363
- _e @ Err ( DataCredentialError :: MismatchedHashDigests ( _, _) ) => {
362
+ Err ( DataCredentialError :: MismatchedHashDigests ( _, _) ) => {
364
363
println ! ( "Digest... ❌ (mismatched data hash digests)" ) ;
365
364
}
366
365
Ok ( _) => {
@@ -408,28 +407,29 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
408
407
Ok ( ( ) )
409
408
}
410
409
411
- fn handle_credential_error ( err : & CredentialError ) {
410
+ fn handle_credential_error ( err : CredentialError ) -> Result < ( ) , CredentialError > {
412
411
match err {
413
- _err @ CredentialError :: VerificationResultError ( _) => {
412
+ CredentialError :: VerificationResultError ( _) => {
414
413
println ! ( "Proof... ❌ Invalid" ) ;
415
414
}
416
- _err @ CredentialError :: NoProofPresent => {
415
+ CredentialError :: NoProofPresent => {
417
416
println ! ( "Proof... ❌ (missing proof)" ) ;
418
417
}
419
- _err @ CredentialError :: MissingVerificationMethod => {
418
+ CredentialError :: MissingVerificationMethod => {
420
419
println ! ( "Proof... ❌ (missing verification method)" ) ;
421
420
}
422
- _err @ CredentialError :: NoIssuerPresent => {
421
+ CredentialError :: NoIssuerPresent => {
423
422
println ! ( "Proof.... ✅" ) ;
424
423
println ! ( "Issuer... ❌ (missing issuer)" ) ;
425
424
}
426
- _err @ CredentialError :: VerifierError ( _) => {
425
+ CredentialError :: VerifierError ( _) => {
427
426
println ! ( "Proof.... ✅" ) ;
428
427
println ! ( "Issuer... ❌ (with verifier error)" ) ;
429
428
}
430
- _err @ CredentialError :: FailedToDecodeJWT => {
429
+ CredentialError :: FailedToDecodeJWT => {
431
430
println ! ( "Proof.... ❌" ) ;
432
431
println ! ( "Issuer... ❌" ) ;
433
432
}
434
433
}
434
+ Err ( err)
435
435
}
0 commit comments