github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/recover12b.gno (about)

     1  package main
     2  
     3  func anotherRecover() {
     4  	if r := recover(); r != nil {
     5  		println(r)
     6  	}
     7  }
     8  
     9  func main() {
    10  	defer func() {
    11  		if r := recover(); r != nil {
    12  			println(r.(string) + ": not another recover")
    13  		}
    14  	}()
    15  	defer func() {
    16  		anotherRecover()
    17  	}()
    18  	defer func() {
    19  		if r := recover(); r != nil {
    20  			panic("panic in defer func")
    21  		}
    22  	}()
    23  
    24  	panic("panic in main")
    25  }
    26  
    27  // Output:
    28  // panic in defer func: not another recover