Skip to content
This repository was archived by the owner on Nov 14, 2017. It is now read-only.

Commit 4330834

Browse files
LHCGregLHCGreg
authored andcommitted
Catch exceptions in npkdiff.
1 parent f435511 commit 4330834

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

npkdiff/CommandLineArgs.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@ class CommandLineArgs
2323
public CommandLineArgs(string[] args)
2424
{
2525
OptionSet optionSet = GetOptionSet();
26-
optionSet.Parse(args);
26+
27+
try
28+
{
29+
optionSet.Parse(args);
30+
}
31+
catch (OptionException ex)
32+
{
33+
Console.Error.WriteLine(ex.Message);
34+
Environment.Exit(1);
35+
}
2736

2837
if (ShowHelp)
2938
{

npkdiff/Program.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,23 @@ class Program
1313
{
1414
static void Main(string[] args)
1515
{
16-
CommandLineArgs cmdline = new CommandLineArgs(args);
16+
try
17+
{
18+
CommandLineArgs cmdline = new CommandLineArgs(args);
1719

18-
// read *.NPK in NpkDir1
19-
// read *.NPK in NpkDir2
20-
// Compare
20+
// read *.NPK in NpkDir1
21+
// read *.NPK in NpkDir2
22+
// Compare
2123

22-
NpkDirContents dir1Contents = GetNpkDirContents(cmdline.NpkDir1);
23-
NpkDirContents dir2Contents = GetNpkDirContents(cmdline.NpkDir2);
24-
NpkDirDifferences differences = dir1Contents.GetDifferences(dir2Contents);
25-
DisplayDifferences(differences);
24+
NpkDirContents dir1Contents = GetNpkDirContents(cmdline.NpkDir1);
25+
NpkDirContents dir2Contents = GetNpkDirContents(cmdline.NpkDir2);
26+
NpkDirDifferences differences = dir1Contents.GetDifferences(dir2Contents);
27+
DisplayDifferences(differences);
28+
}
29+
catch (Exception ex)
30+
{
31+
Console.Error.WriteLine("Unexpected error: {0}", ex.Message);
32+
}
2633
}
2734

2835
static NpkDirContents GetNpkDirContents(string npkDir)

0 commit comments

Comments
 (0)