@@ -197,24 +197,26 @@ impl<T: WalHook> WalMethodsHook<T> {
197
197
}
198
198
199
199
macro_rules! catch_panic {
200
- ( $( $body: tt) * ) => {
201
- let ret = catch_unwind( move || {
202
- $( $body) *
203
- } ) ;
204
-
205
- match ret {
206
- Ok ( x) => x,
207
- Err ( e) => {
208
- let error = if let Some ( s) = e. downcast_ref:: <String >( ) {
209
- s. as_str( )
210
- } else if let Some ( s) = e. downcast_ref:: <& str >( ) {
211
- s
212
- } else {
213
- "unknown"
214
- } ;
215
- let bt = std:: backtrace:: Backtrace :: force_capture( ) ;
216
- tracing:: error!( "panic in call to xframe: {error}:\n {bt}" ) ;
217
- resume_unwind( e)
200
+ ( $name: literal, { $( $body: tt) * } ) => {
201
+ {
202
+ let ret = catch_unwind( move || {
203
+ $( $body) *
204
+ } ) ;
205
+
206
+ match ret {
207
+ Ok ( x) => x,
208
+ Err ( e) => {
209
+ let error = if let Some ( s) = e. downcast_ref:: <String >( ) {
210
+ s. as_str( )
211
+ } else if let Some ( s) = e. downcast_ref:: <& str >( ) {
212
+ s
213
+ } else {
214
+ "unknown"
215
+ } ;
216
+ let bt = std:: backtrace:: Backtrace :: force_capture( ) ;
217
+ tracing:: error!( "panic in call to {}: {error}:\n {bt}" , $name) ;
218
+ resume_unwind( e)
219
+ }
218
220
}
219
221
}
220
222
} ;
@@ -320,13 +322,13 @@ pub extern "C" fn xUndo<T: WalHook>(
320
322
func : Option < unsafe extern "C" fn ( * mut c_void , u32 ) -> i32 > ,
321
323
undo_ctx : * mut c_void ,
322
324
) -> i32 {
323
- catch_panic ! {
325
+ catch_panic ! ( "xUndo" , {
324
326
assert!( !wal. is_null( ) ) ;
325
327
let wal = unsafe { & mut * wal } ;
326
328
let orig_methods = get_orig_methods:: <T >( wal) ;
327
329
let orig_xundo = orig_methods. xUndo. unwrap( ) ;
328
330
T :: on_undo( wal, func, undo_ctx, orig_xundo)
329
- }
331
+ } )
330
332
}
331
333
332
334
#[ allow( non_snake_case) ]
@@ -337,12 +339,12 @@ pub extern "C" fn xSavepoint<T: WalHook>(wal: *mut Wal, wal_data: *mut u32) {
337
339
338
340
#[ allow( non_snake_case) ]
339
341
pub extern "C" fn xSavepointUndo < T : WalHook > ( wal : * mut Wal , wal_data : * mut u32 ) -> i32 {
340
- catch_panic ! {
342
+ catch_panic ! ( "xSavepointUndo" , {
341
343
let wal = unsafe { & mut * wal } ;
342
344
let orig_methods = get_orig_methods:: <T >( wal) ;
343
345
let orig_xsavepointundo = orig_methods. xSavepointUndo. unwrap( ) ;
344
346
T :: on_savepoint_undo( wal, wal_data, orig_xsavepointundo)
345
- }
347
+ } )
346
348
}
347
349
348
350
#[ allow( non_snake_case) ]
@@ -354,7 +356,7 @@ pub extern "C" fn xFrames<T: WalHook>(
354
356
is_commit : c_int ,
355
357
sync_flags : c_int ,
356
358
) -> c_int {
357
- catch_panic ! {
359
+ catch_panic ! ( "xFrames" , {
358
360
assert!( !wal. is_null( ) ) ;
359
361
let wal = unsafe { & mut * wal } ;
360
362
let orig_methods = get_orig_methods:: <T >( wal) ;
@@ -369,7 +371,7 @@ pub extern "C" fn xFrames<T: WalHook>(
369
371
sync_flags,
370
372
orig_xframe,
371
373
)
372
- }
374
+ } )
373
375
}
374
376
375
377
#[ tracing:: instrument( skip( wal, db) ) ]
@@ -386,7 +388,7 @@ pub extern "C" fn xCheckpoint<T: WalHook>(
386
388
frames_in_wal : * mut c_int ,
387
389
backfilled_frames : * mut c_int ,
388
390
) -> i32 {
389
- catch_panic ! {
391
+ catch_panic ! ( "xCheckpoint" , {
390
392
let wal = unsafe { & mut * wal } ;
391
393
let orig_methods = get_orig_methods:: <T >( wal) ;
392
394
let orig_xcheckpoint = orig_methods. xCheckpoint. unwrap( ) ;
@@ -403,7 +405,7 @@ pub extern "C" fn xCheckpoint<T: WalHook>(
403
405
backfilled_frames,
404
406
orig_xcheckpoint,
405
407
)
406
- }
408
+ } )
407
409
}
408
410
409
411
#[ allow( non_snake_case) ]
0 commit comments