sending an Exception and print it
Dan Killebrew
nospam at gmail.com
Sat Dec 21 15:28:36 PST 2013
I'm sending an exception from a worker thread to the owner thread
to be logged/printed. Using DMD64 D Compiler v2.064
http://dpaste.dzfl.pl/7c8b68bd
Using std.concurrency prevents me from passing a naked Exception.
So the owner receives either a shared or immutable Exception.
I can't format a shared Exception:
/usr/include/dmd/phobos/std/format.d(2602): Error: static assert
"unable to format shared objects"
I can't format an immutable Exception:
/usr/include/dmd/phobos/std/format.d(2610): Error: template
instance formatObject!(Appender!string, immutable(Exception),
char) does not match template declaration formatObject(Writer, T,
Char)(ref Writer w, ref T val, ref FormatSpec!Char f) if
(hasToString!(T, Char))
What gives? I expected the immutable Exception to be formattable.
My current workaround is to cast to const Exception. Is there
something else I should be doing here?
More information about the Digitalmars-d-learn
mailing list