Skip to content

Instantly share code, notes, and snippets.

@marrub--

marrub--/main.d Secret

Created May 27, 2017 13:18
Show Gist options
  • Save marrub--/84200d3f86b2cd1af258752404039455 to your computer and use it in GitHub Desktop.
Save marrub--/84200d3f86b2cd1af258752404039455 to your computer and use it in GitHub Desktop.
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