Skip to content
This repository has been archived by the owner on Jun 4, 2018. It is now read-only.

Commit

Permalink
Improve error reporting for startup errors.
Browse files Browse the repository at this point in the history
Since any exceptions thrown from Tasks are combined in an
AggregateException, these must be unwrapped to get the actual error
before reporting them in an error dialog.  Failure to do so results in
useless error messages like "One or more errors occurred."
  • Loading branch information
jrick committed Feb 25, 2016
1 parent f2507cf commit ccbe725
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Paymetheus/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ public App()

Application.Current.Dispatcher.UnhandledException += (sender, args) =>
{
MessageBox.Show(args.Exception.Message, "Error");
var ex = args.Exception;
var ae = ex as AggregateException;
Exception inner;
if (ae != null && ae.TryUnwrap(out inner))
{
ex = inner;
}
MessageBox.Show(ex.Message, "Error");
UncleanShutdown();
Application.Current.Shutdown(1);
};
Expand Down

0 comments on commit ccbe725

Please sign in to comment.