github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0172.yml (about) 1 doc_meta: | 2 folder: flow-controll 3 title: guaranteed final step to ensure clean up/rescue 4 head: | 5 Introduce to use finally/rescue in task step for a guranteed cleanup when task step has got panic 6 7 sections: 8 - title: Demo 9 log: yes 10 11 12 - title: what will happen if there is no rescue for the task without rescue 13 content: | 14 This showcases that the finally step invokes the close_file task to ensure the opened file is closed 15 16 The task will fail if there is no rescue to be "true", in this case, user choose to fail the task, or if rescue is set, then the execution will continue to the next func step call 17 18 19 related: 20 refs: 21 - title: shell func 22 link: ../../quick-start/c0002/ 23 - title: error handling 24 link: ../../test-debug/error_handling/ 25 - title: shell step fails 26 link: ../../flow-controll/f0171/ 27 28 notes: 29 - add feature of finally run code 30 - add feature to rescue from panic 31 32 tasks: 33 34 - 35 name: task 36 task: 37 38 - 39 func: cmd 40 desc: step 1 41 do: 42 - name: print 43 cmd: step 1 44 - name: panic 45 - name: print 46 cmd: extra step ......... it will never reach here 47 rescue: true 48 finally: close_file 49 50 - 51 func: cmd 52 desc: step 2 53 do: 54 - name: print 55 cmd: step 2 56 57 - 58 name: close_file 59 task: 60 - 61 func: shell 62 name: close_file 63 desc: | 64 ensure the opened file is closed 65 do: 66 - echo "close the file ....."