Oh, I should mention that if you use core.thread explicitly, any unhandled exception will be re-thrown in the context of whoever joins that thread.
On Aug 8, 2012, at 1:52 AM, Martin Krejcirik <mk-j...@i-line.cz> wrote: > Hi Ali, > > On 8.8.2012 5:36, Ali Çehreli wrote: >> The OwnerTerminated and LinkTerminated exceptions can be received as >> messages as well. The following code demonstrates this for the >> OwnerTerminated exception: > > I meant how can I print the actual exception from the thread, including > it's error message, stack trace etc. Consider code like this, it just > ends without any error message: > > import std.concurrency, std.stdio; > > void main() > { > writeln("main start"); > spawn(&child); > for (int i=0; i<1_000_000_000; i++) {}; > writeln("main end"); > } > > void child() > { > writeln("thread start"); > for (int i=0; i<100_000; i++) {}; > writeln("thread end"); > throw new Exception("exception from thread"); > } > > If I use spawnLinked, I know the thread ended, but still no original > exception. If I change main() to terminate before child(), it actually > waits until the child finishes and prints the exception, so there has to > be a way. > > -- > mk