collectException range violation

Ali Çehreli acehreli at yahoo.com
Tue Feb 19 17:19:54 PST 2013


On 02/19/2013 04:38 PM, cal wrote:
 > Is this example from the docs still meant to work?
 >
 > int[] a = new int[3];
 > int b;
 > assert(collectException(a[4], b));

The example is wrong. a[4] throws an Error (not Exception) but 
collectException catches Exception by default.

Additionally, the example is doing something that is recommended 
against: Catching Error or a descendent of it.

Still, it can be told to catch by Error:

     assert(collectException!Error(a[4], b));

Ali



More information about the Digitalmars-d-learn mailing list