Comparing Exceptions and Errors

Ali Çehreli acehreli at yahoo.com
Sat Jun 4 01:38:59 UTC 2022


On 6/3/22 18:17, Steven Schveighoffer wrote:

 > If a thread does not catch an error and end the program

No, the thread dies and the main thread doesn't know anything about it. 
Unless if std.concurrency is being used and the main thread looks for 
and receives a LinkTerminated message. (If spawnLinked was used to start 
the thread.)

But still, there is no trace of the Error. So I do the following in my 
thread functions:

void myThread() {
   try {

   } catch (Exception exc) {
      // ...

   } catch (Error exc) {
     // Report on stderr
     exit(1); // Yes, takes down the main thread.
              // Could choose to do otherwise...
   }
}

Ali



More information about the Digitalmars-d-learn mailing list