Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
60 lines (56 loc) · 1.76 KB
/
Copy pathProgram.cs
File metadata and controls
60 lines (56 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System.Diagnostics.CodeAnalysis;
namespace OpenClaw.GatewayRecovery;
/// <summary>
/// The windowless sign-in helper. Both logon recovery lanes, the logon task
/// and the Startup-folder shortcut, start this executable through its
/// package-qualified execution alias.
/// </summary>
internal static class Program
{
[SuppressMessage(
"Design",
"CA1031:Do not catch general exception types",
Justification =
"This is the process last-chance handler of a process nobody watches. " +
"An escaping exception would end in an unexplained exit or a crash " +
"report instead of a host log entry and exit code 1.")]
private static int Main()
{
using HostDiagnosticLog? log = TryCreateLog();
void Write(string message)
{
try
{
log?.Write(message);
}
catch (Exception exception) when (
exception is IOException or UnauthorizedAccessException or ObjectDisposedException)
{
}
}
try
{
return GatewayRecoveryStart.Run(
GatewayRecoveryEnvironment.Current(),
new HiddenProcessRunner(),
Write);
}
catch (Exception exception)
{
Write($"Sign-in helper: unhandled failure: {exception}");
return GatewayRecoveryStart.FailureExitCode;
}
}
private static HostDiagnosticLog? TryCreateLog()
{
try
{
return HostDiagnosticLog.Create();
}
catch (Exception exception) when (
exception is IOException or UnauthorizedAccessException or InvalidOperationException)
{
return null;
}
}
}