On Wednesday, 12 February 2014 at 03:31:38 UTC, Nick Sabalausky
wrote:
Hmm, my custom toString isn't being executed. Am I doing
something wrong here? Same result if I inherit direct from
Throwable instead of Exception.
class Fail : Exception
{
private this()
{
super(null);
}
private static Fail opCall(string msg, string
file=__FILE__, int line=__LINE__)
{
auto f = cast(Fail) cast(void*) Fail.classinfo.init;
f.msg = msg;
f.file = file;
f.line = line;
return f;
}
override string toString()
{
writeln("In Fail.toString()");
return "someapp: ERROR: "~msg;
}
}
It looks like this has changed, and the method that's called now
is:
void toString(scope void delegate(in char[]) sink) const;
I suspect this has broken a lot of custom exception messages,
since everything in core.exception still uses toString() for its
output.