Exit D Program in Static Constructor

153 views Asked by At

I have a static constructor like this:

File errorLog;
static this() {
    try {
        errorLog = File("./log/log.txt", "w");
    } catch(Throwable ex) {
        // STOP PROGRAM EXECUTION
    }
}

How would I stop the program execution when the opening of the file fails?

1

There are 1 answers

4
Kozzi11 On BEST ANSWER

Use core.runtime to terminate druntime http://dlang.org/phobos/core_runtime.html#.Runtime.terminate and exit from core.stdc.stdlib