-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
45 lines (39 loc) · 1.43 KB
/
Program.cs
File metadata and controls
45 lines (39 loc) · 1.43 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
using System;
using System.Threading.Tasks;
using TreeBasedCli;
using TreeBasedCli.Exceptions;
namespace Samples.AnimalKingdom
{
internal class Program
{
private static async Task<int> Main(string[] arguments)
{
ArgumentHandlerSettings argumentHandlerSettings = ArgumentHandlerSettingsBuilder.Build();
var argumentHandler = new ArgumentHandler(argumentHandlerSettings);
try
{
await argumentHandler.HandleAsync(arguments);
}
catch (MessageOnlyException exception)
{
Console.WriteLine(exception.Message);
return 1;
}
catch (Exception exception)
{
string type = exception.GetType().Name;
Console.WriteLine($"Program aborted with an exception of type '{type}':");
Console.WriteLine($"\n{exception.Message}");
Console.WriteLine($"\n{exception.StackTrace}");
if (exception.InnerException is not null)
{
Console.WriteLine("\nInner exception:");
Console.WriteLine($"\n{exception.InnerException.Message}");
Console.WriteLine($"\n{exception.InnerException.StackTrace}");
}
return 1;
}
return 0;
}
}
}