@@ -267,14 +267,26 @@ impl StacksChainState {
267
267
} )
268
268
} )
269
269
. map_err ( Error :: ClarityError )
270
- . unwrap ( )
270
+ . unwrap_or_else ( |e| {
271
+ error ! (
272
+ "FATAL: Failed to query account for {:?}: {:?}" ,
273
+ principal, & e
274
+ ) ;
275
+ panic ! ( ) ;
276
+ } )
271
277
}
272
278
273
279
pub fn get_nonce < T : ClarityConnection > ( clarity_tx : & mut T , principal : & PrincipalData ) -> u64 {
274
280
clarity_tx
275
281
. with_clarity_db_readonly ( |ref mut db| db. get_account_nonce ( principal) )
276
282
. map_err ( |x| Error :: ClarityError ( x. into ( ) ) )
277
- . unwrap ( )
283
+ . unwrap_or_else ( |e| {
284
+ error ! (
285
+ "FATAL: Failed to query account nonce for {:?}: {:?}" ,
286
+ principal, & e
287
+ ) ;
288
+ panic ! ( ) ;
289
+ } )
278
290
}
279
291
280
292
pub fn get_account_ft (
@@ -337,7 +349,13 @@ impl StacksChainState {
337
349
snapshot. save ( ) ?;
338
350
Ok ( ( ) )
339
351
} )
340
- . expect ( "FATAL: failed to debit account" )
352
+ . unwrap_or_else ( |e| {
353
+ error ! (
354
+ "FATAL: failed to debit account {:?} for {} uSTX: {:?}" ,
355
+ principal, amount, & e
356
+ ) ;
357
+ panic ! ( ) ;
358
+ } )
341
359
}
342
360
343
361
/// Called each time a transaction sends STX to this principal.
@@ -358,7 +376,13 @@ impl StacksChainState {
358
376
info ! ( "{} credited: {} uSTX" , principal, new_balance) ;
359
377
Ok ( ( ) )
360
378
} )
361
- . expect ( "FATAL: failed to credit account" )
379
+ . unwrap_or_else ( |e| {
380
+ error ! (
381
+ "FATAL: failed to credit account {:?} for {} uSTX: {:?}" ,
382
+ principal, amount, & e
383
+ ) ;
384
+ panic ! ( ) ;
385
+ } )
362
386
}
363
387
364
388
/// Called during the genesis / boot sequence.
@@ -374,7 +398,13 @@ impl StacksChainState {
374
398
snapshot. save ( ) ?;
375
399
Ok ( ( ) )
376
400
} )
377
- . expect ( "FATAL: failed to credit account" )
401
+ . unwrap_or_else ( |e| {
402
+ error ! (
403
+ "FATAL: failed to credit genesis account {:?} for {} uSTX: {:?}" ,
404
+ principal, amount, & e
405
+ ) ;
406
+ panic ! ( ) ;
407
+ } )
378
408
}
379
409
380
410
/// Increment an account's nonce
@@ -385,11 +415,19 @@ impl StacksChainState {
385
415
) {
386
416
clarity_tx
387
417
. with_clarity_db ( |ref mut db| {
388
- let next_nonce = cur_nonce. checked_add ( 1 ) . expect ( "OUT OF NONCES" ) ;
418
+ let next_nonce = cur_nonce
419
+ . checked_add ( 1 )
420
+ . unwrap_or_else ( || panic ! ( "OUT OF NONCES" ) ) ;
389
421
db. set_account_nonce ( & principal, next_nonce) ?;
390
422
Ok ( ( ) )
391
423
} )
392
- . expect ( "FATAL: failed to set account nonce" )
424
+ . unwrap_or_else ( |e| {
425
+ error ! (
426
+ "FATAL: failed to update account nonce for account {:?} from {}: {:?}" ,
427
+ principal, cur_nonce, & e
428
+ ) ;
429
+ panic ! ( ) ;
430
+ } )
393
431
}
394
432
395
433
/// Schedule a miner payment in the future.
0 commit comments