-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
55 lines (51 loc) · 1.24 KB
/
Program.cs
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
// Copyright Bastian Eicher et al.
// Licensed under the GNU Lesser Public License
using System.Net;
using System.Security;
using NanoByte.Common.Net;
using NanoByte.Common.Tasks;
using NDesk.Options;
using ZeroInstall.Publish.Capture.Cli;
NetUtils.ApplyProxy();
using var handler = new AnsiCliTaskHandler();
try
{
new CaptureCommand(args is [] ? ["--help"] : args, handler).Execute();
return (int)ExitCode.OK;
}
#region Error handling
catch (OperationCanceledException)
{
return (int)ExitCode.UserCanceled;
}
catch (Exception ex) when (ex is ArgumentException or OptionException or KeyNotFoundException)
{
handler.Error(ex);
return (int)ExitCode.InvalidArguments;
}
catch (WebException ex)
{
handler.Error(ex);
return (int)ExitCode.WebError;
}
catch (InvalidDataException ex)
{
handler.Error(ex);
return (int)ExitCode.InvalidData;
}
catch (IOException ex)
{
handler.Error(ex);
return (int)ExitCode.IOError;
}
catch (Exception ex) when (ex is UnauthorizedAccessException or SecurityException)
{
handler.Error(ex);
return (int)ExitCode.AccessDenied;
}
catch (NotSupportedException ex)
{
handler.Error(ex);
return (int)ExitCode.NotSupported;
}
#endregion