Problem collecting exception from a passed function

Gary Willoughby dev at nomad.so
Tue Nov 26 11:45:22 PST 2013


Why in the following snippet does foo() not collect the exception 
correctly? It is always null.

import std.exception;
import std.stdio;

public void foo(A : Exception, B)(lazy B func)
{
	auto exception = collectException(func());
	writefln("%s", exception); // This is always null.
}

void bar()
{
	throw new Exception("This is thrown");
}

void main(string[] args)
{
	foo!(Exception)(&bar);
}


More information about the Digitalmars-d-learn mailing list