2.44. Dynamic exception handling using goto

Non local gotos are very useful for a form of exception handling. Consider the following example:
Start felix section to tut/tutorial/tut-1.44-0.flx[1 /1 ]
     1: #line 4345 "./lpsrc/flx_tutorial.pak"
     2: //Check exceptions
     3: #import <flx.flxh>
     4: 
     5: proc bad_calc(err: int -> void)
     6: {
     7:   // do some work, detect an error
     8:   err 1; // throw exception
     9: }
    10: 
    11: proc main
    12: {
    13:   proc err(errno:int)
    14:   {
    15:     print "error "; print errno;
    16:     print " -- aborting"; endl;
    17:     goto resume;
    18:   }
    19:   bad_calc err of (int);
    20:   print "no error"; endl;
    21: resume:>
    22:   print "error handled, continuing"; endl;
    23: }
    24: main;
End felix section to tut/tutorial/tut-1.44-0.flx[1]
Start data section to tut/tutorial/tut-1.44-0.expect[1 /1 ]
     1: error 1 -- aborting
     2: error handled, continuing
End data section to tut/tutorial/tut-1.44-0.expect[1]
Here, we establish a handler for an error, which is effectively established at the label resume: the handler is passed explicitly to the routine which may 'raise' it.