1

我有一个像这样的静态构造函数:

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

打开文件失败时如何停止程序执行?

4

1 回答 1

1

使用 core.runtime 终止 druntime http://dlang.org/phobos/core_runtime.html#.Runtime.terminate并退出 core.stdc.stdlib

于 2014-01-01T17:38:47.777 回答