Almost all of my programs are in the following pattern:
import std.stdio; void main(string[] args) { version (unittest) { // Don't execute the main program when unit testing return; } try { // Dispatch to the actual "main" function doIt(args); } catch (Exception exc) { // Note .msg because we don't want to print stack trace stderr.writefln!"ERROR: %s"(exc.msg); } catch (Error err) { // Note NO .msg because we DO want to print stack trace stderr.writefln!"ERROR: %s"(err); } } // This is the actual "main" void doIt(string[] args) { // ... } Ali