【发布时间】:2014-01-01 15:36:43
【问题描述】:
我有一个像这样的静态构造函数:
File errorLog;
static this() {
try {
errorLog = File("./log/log.txt", "w");
} catch(Throwable ex) {
// STOP PROGRAM EXECUTION
}
}
打开文件失败时如何停止程序执行?
【问题讨论】:
-
不是任何意义上的专家,但是
import core.stdc.stdlib;并使用exit(-1);怎么样? -
@JoachimIsaksson 这不会破坏 D 运行时。
标签: d exit static-constructor