Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Blanket catch-all for Setup errors which shows nice dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Apr 8, 2022
1 parent 87550b5 commit bafc994
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Update/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Squirrel.SimpleSplat;
using Squirrel.SimpleSplat;
using Squirrel.Json;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -81,7 +81,22 @@ static int executeCommandLine(string[] args)

switch (opt.updateAction) {
case UpdateAction.Setup:
Setup(opt.target, opt.silentInstall, opt.checkInstall).Wait();
try {
Setup(opt.target, opt.silentInstall, opt.checkInstall).Wait();
} catch (Exception ex) when (!opt.silentInstall && !opt.checkInstall) {
// when not in silent mode, we should endeavor to show a message.
// we will also exit code 0, so Setup.exe does not think
// it was an outright crash and show another error dialog.
Log.FatalException("Encountered fatal unhandled exception.", ex);
Windows.User32MessageBox.Show(
IntPtr.Zero,
"Setup encountered fatal error: " + ex.Message + Environment.NewLine
+ "There may be more detailed information in '%localappdata%\\SquirrelClowdTemp\\Squirrel.log'. "
+ "Please contact the application author.",
"Setup Error",
Windows.User32MessageBox.MessageBoxButtons.OK,
Windows.User32MessageBox.MessageBoxIcon.Error);
}
break;
case UpdateAction.Install:
var progressSource = new ProgressSource();
Expand Down

0 comments on commit bafc994

Please sign in to comment.