Skip to content

Commit adfddf1

Browse files
committed
[增加]1. 增加导出协议文件的错误处理
1 parent cb7af6e commit adfddf1

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

ProtoExport/Program.cs

+21-12
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,32 @@ internal static class Program
66
{
77
private static int Main(string[] args)
88
{
9-
var launcherOptions = Parser.Default.ParseArguments<LauncherOptions>(args).Value;
10-
if (launcherOptions == null)
9+
try
1110
{
12-
Console.WriteLine("参数错误,解析失败");
13-
return 1;
14-
}
11+
var launcherOptions = Parser.Default.ParseArguments<LauncherOptions>(args).Value;
12+
if (launcherOptions == null)
13+
{
14+
Console.WriteLine("参数错误,解析失败");
15+
throw new Exception("参数错误,解析失败");
16+
}
17+
18+
if (!Enum.TryParse<ModeType>(launcherOptions.Mode, true, out var modeType))
19+
{
20+
Console.WriteLine("不支持的运行模式");
21+
throw new Exception("不支持的运行模式");
22+
}
1523

16-
if (!Enum.TryParse<ModeType>(launcherOptions.Mode, true, out var modeType))
24+
ProtoBufMessageHandler.Start(launcherOptions, modeType);
25+
Console.WriteLine("导出成功,请查看日志");
26+
}
27+
catch (Exception e)
1728
{
18-
Console.WriteLine("不支持的运行模式");
19-
return 1;
29+
Console.WriteLine("导出失败,请检查错误信息");
30+
Console.WriteLine(e);
31+
Console.ReadKey();
32+
throw;
2033
}
2134

22-
ProtoBufMessageHandler.Start(launcherOptions, modeType);
23-
24-
Console.WriteLine("导出成功,按任意键退出");
25-
Console.ReadKey();
2635
return 0;
2736
}
2837
}

0 commit comments

Comments
 (0)