December 21, 2013 sending an Exception and print it | ||||
---|---|---|---|---|
| ||||
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? |
December 21, 2013 Re: sending an Exception and print it | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dan Killebrew | I just wanted to add that the "can't format immutable Exception" also prevents me from doing this: auto exception = receiveOnly!(immutable Exception)(); because receiveOnly creates a tuple which implements a toString that uses indirectly uses formatObject. So I'm forced to use the slightly more clunky recieve() as seen on DPaste. |
Copyright © 1999-2021 by the D Language Foundation