Skip to content

Commit

Permalink
修改错误收集信息
Browse files Browse the repository at this point in the history
  • Loading branch information
dawn-lc committed May 23, 2021
1 parent ca43623 commit be9e44e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
37 changes: 16 additions & 21 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static bool StartupParametersCheck(List<string> StartupParameters, strin
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.WriteLine("启动参数存在错误!请检查参数:[" + ParameterFlag + "]");
if (ProgramParameter.DebugMode) { Console.Write(ex.ToString()); }
throw ex;
}
Expand Down Expand Up @@ -146,7 +146,6 @@ private static bool Initialize(string[] args)
Console.WriteLine("上次检查更新: " + config["CheckUpgrade"].ToObject<DateTime>().ToLocalTime().ToString());
if (config["CheckUpgrade"].ToObject<DateTime>() < (DateTime.Now - new TimeSpan(1, 0, 0)))
{
Console.WriteLine("正在检查更新...");
Console.WriteLine("正在从github.com获取最新版本信息...");
if (Upgrade.CheckUpgrade(new Uri("https://api.github.com/repos/" + ProgramParameter.Developer + "/" + ProgramParameter.AppName + "/releases/latest"), Http.Method.GET, new Dictionary<string, string>() { ["user-agent"] = ProgramParameter.AppName + " " + string.Join(".", ProgramParameter.Version) + ";" }))
{
Expand Down Expand Up @@ -179,12 +178,10 @@ private static bool Initialize(string[] args)
ProgramParameter.ArchiveFile = new FileInfo(Console.ReadLine());
}
}
catch (Exception)
catch (Exception ex)
{
Console.WriteLine("尝试读取压缩包信息时出现错误!(按任意键退出程序)");
Console.ReadKey();
return false;

Console.WriteLine("尝试读取压缩包信息时出现错误!");
throw ex;
}
}
else
Expand All @@ -210,12 +207,10 @@ private static bool Initialize(string[] args)
ProgramParameter.Dictionary = new FileInfo(Console.ReadLine());
}
}
catch (Exception)
catch (Exception ex)
{
Console.WriteLine("尝试读取密码字典时出现错误!(按任意键退出程序)");
Console.ReadKey();
return false;

Console.WriteLine("尝试读取密码字典时出现错误!");
throw ex;
}
}
else
Expand All @@ -238,9 +233,8 @@ private static bool Initialize(string[] args)
catch (Exception ex)
{
Console.Write("启动参数存在错误!请检查参数:[-T]");
Console.ReadLine();
if (ProgramParameter.DebugMode) { Console.Write(ex.ToString()); }
return false;
throw ex;
}
if (ProgramParameter.DecryptArchiveThreadCount > (Environment.ProcessorCount - 1))
{
Expand Down Expand Up @@ -334,7 +328,9 @@ void StoreOutput(object o, DataReceivedEventArgs e)
Console.Write(string.Join(Environment.NewLine, Error.ToArray()));
Console.WriteLine(ex.ToString());
}
return new Dictionary<string, List<string>> { ["RunTimeError"] = new List<string> { ex.ToString() } };
Console.WriteLine("执行 "+ Program.FullName + string.Join(" ", Arguments)+ " 失败!");
throw ex;
//return new Dictionary<string, List<string>> { ["RunTimeError"] = new List<string> { ex.ToString() } };
}
finally
{
Expand Down Expand Up @@ -362,6 +358,8 @@ public Main(string[] args)
catch (Exception ex)
{
ravenClient.Capture(new SentryEvent(ex));
Console.WriteLine("错误信息已上报(按任意键退出程序)");
Console.ReadKey();
}
return;
}
Expand All @@ -377,8 +375,7 @@ private void MainProgram()
Console.ReadKey();
if (string.IsNullOrEmpty(ReadRegeditValue("SOFTWARE\\7-Zip", "Path").ToString()))
{
Console.WriteLine("调用完全体7Zip失败,请检查7Zip安装情况!(按任意键退出程序)");
Console.ReadKey();
Console.WriteLine("调用完全体7Zip失败,请检查7Zip安装情况!");
Process.Start("https://sparanoid.com/lab/7z/");
throw new Exception("7Zip Error!");
}
Expand All @@ -390,8 +387,7 @@ private void MainProgram()

if (!RunProgram(ProgramParameter.ArchiveDecryptionProgram, new string[] { "t", "\"" + ProgramParameter.ArchiveFile.FullName + "\"", "-p" }).TryGetValue("Output", out List<string> Output))
{
Console.WriteLine("压缩包损坏 或 不是支持的压缩包!(按任意键退出)");
Console.ReadKey();
Console.WriteLine("压缩包损坏 或 不是支持的压缩包!");
throw new Exception("ArchiveFile Error!");
}
else
Expand Down Expand Up @@ -421,9 +417,8 @@ private void MainProgram()
}
catch (Exception ex)
{
Console.WriteLine("尝试读取密码字典时出现错误!(按任意键退出程序)");
Console.WriteLine("尝试读取密码字典时出现错误!");
if (ProgramParameter.DebugMode) { Console.Write(ex.ToString()); }
Console.ReadKey();
throw ex;
}

Expand Down
6 changes: 3 additions & 3 deletions UpgradeModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static bool CheckUpgrade(Uri uri, Http.Method method, Dictionary<string,
{
Console.WriteLine("检查更新失败!请联系开发者进行修复。");
Process.Start(ProgramParameter.AppHomePage);
throw new Exception("错误的版本信息格式! "+ ReleasesLatestInfo.ToString());
throw new Exception("错误的版本信息格式! \r\n" + ReleasesLatestInfo.ToString());
}

switch (ComparisonVersion(ProgramParameter.Version, LatestVersion.ToArray()))
Expand Down Expand Up @@ -158,7 +158,7 @@ public static bool CheckUpgrade(Uri uri, Http.Method method, Dictionary<string,
{
Console.WriteLine("检查更新失败!请检查您的网络情况。");
Process.Start(ProgramParameter.AppHomePage);
return false;
throw new Exception("检查更新失败!\r\n" + ReleasesLatestInfoData.GetResponseStatusCode() + "\r\n" + ReleasesLatestInfoData.GetResponseString());
}
}
}
Expand All @@ -167,7 +167,7 @@ public static bool CheckUpgrade(Uri uri, Http.Method method, Dictionary<string,
Console.WriteLine("检查更新失败!请检查您的网络情况。");
Console.WriteLine(ex.ToString());
Process.Start(ProgramParameter.AppHomePage);
return false;
throw new Exception("检查更新失败!\r\n" + ex.ToString());
}

}
Expand Down

0 comments on commit be9e44e

Please sign in to comment.