1.43. 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/examples/tut_beg151.flx[1 /1 ]
     1: #line 2331 "./lpsrc/flx_tutorial.pak"
     2: #import <flx.flxh>
     3: 
     4: proc bad_calc(err: int -> void)
     5: {
     6:   // do some work, detect an error
     7:   err 1; // throw exception
     8: }
     9: 
    10: proc main
    11: {
    12:   proc err(errno:int)
    13:   {
    14:     print "error "; print errno;
    15:     print " -- aborting"; endl;
    16:     goto resume;
    17:   }
    18:   bad_calc err of (int);
    19:   print "no error"; endl;
    20: resume:>
    21:   print "error handled, continuing"; endl;
    22: }
    23: main;
    24: 
End felix section to tut/examples/tut_beg151.flx[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.