// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; namespace E { public class Program { public static void M1(int v1, List err) { Console.WriteLine("M1"); if(v1 < 1) { err.Add("v1 is too small"); } } public static void M2(int v2, List err) { Console.WriteLine("M2"); if(v2 < 1) { throw new Exception("v2 is too small"); } } public static void M3(int v3, List err) { Console.WriteLine("M3"); } public static void BL(int v1, int v2, int v3, List err) { try { M1(v1, err); M2(v2, err); M3(v3, err); } catch(Exception ex) { err.Add(ex.Message); } } public static void PL(int v1, int v2, int v3) { List err = new List(); BL(v1, v2, v3, err); foreach(string e in err) { Console.WriteLine(e); } } public static void Main(string[] args) { PL(0, 0, 0); } } }