using System; namespace Exceptions { class LoException : System.Exception { public this(){} } class HiException : System.Exception { public this(){} } public module App { mutable Lo : int; mutable Hi : int; mutable count : int; public Main(args : array[string]) : void { def n = int.Parse(args[0]); for (count = 0; count < n; count = count + 1) { SomeFunction(); }; def bldr = System.Text.StringBuilder(100); def _ = bldr.Append("Exceptions: HI=").Append(Hi). Append(" / LO=").Append(Lo); Console.WriteLine(bldr.ToString()); } public SomeFunction() : void { try { HiFunction(); } catch { | e => Console.WriteLine("We shouldn't get here: " + e.Message); } } public HiFunction() : void { try { LoFunction(); } catch { | _ is HiException => Hi = Hi + 1; } } public LoFunction() : void { try { BlowUp(); } catch { | _ is LoException => Lo = Lo + 1; } } public BlowUp() : void { if ((count % 2) == 0) { throw LoException(); } else { throw HiException(); } } } }