-
-
Save marrub--/84200d3f86b2cd1af258752404039455 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tk = tkd.tkdapplication; | |
import std.conv; | |
class Application : tk.TkdApplication | |
{ | |
private void crashTheProgram(tk.CommandArgs) | |
{throw new Error("whoops");} | |
override protected void initInterface() | |
{ | |
mainWindow.setTitle("Oh No"); | |
new tk.Button("Attempt to Crash").setCommand(&this.crashTheProgram).pack; | |
} | |
} | |
int main(string[] args) | |
{ | |
try | |
{ | |
new Application().run; | |
return 0; | |
} | |
// as an example of it not at least rethrowing, this code is never run: | |
catch(Throwable exc) | |
{ | |
auto stacktrace = exc.info.to!string; | |
auto excmsg = | |
("Error: " ~ exc.msg)~ | |
(stacktrace.length ? "\n\nStack trace:\n" ~ stacktrace : "No stack trace available"); | |
new tk.MessageDialog("Whoops") | |
.setMessage(excmsg) | |
.setDetailMessage("An unrecoverable error occurred!") | |
.setIcon("error") | |
.setType("ok") | |
.show; | |
return 1; | |
} | |
} | |
// EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment