Skip to content

Commit

Permalink
fix: 修复当输入非法十六进制时程序可能会异常退出的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
leven99 committed Oct 25, 2019
1 parent 9c36453 commit cd05d80
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions ViewModels/MainWindowVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ public bool HexSend

if (HexSend == true)
{
DepictInfo = string.Format(cultureInfo, "请输入十六进制数据用空格隔开,比如A0 B1 C2 D3");
DepictInfo = string.Format(cultureInfo, "请输入合法十六进制数据,且用空格隔开,比如A0 B1 C2 D3 E4 F5");
}
else
{
Expand Down Expand Up @@ -829,18 +829,22 @@ await SerialPortBase.BaseStream.WriteAsync(SerialPortBase.Encoding.GetBytes("\r\
{
DepictInfo = e.Message;
}
catch (IndexOutOfRangeException)
catch(OverflowException)
{
DepictInfo = string.Format(cultureInfo, "正在试图执行越界访问,请通过菜单栏<帮助>报告问题!");
DepictInfo = string.Format(cultureInfo, "请输入合法十六进制数据,且用空格隔开,比如A0 B1 C2 D3 E4 F5");
}
catch (NotFiniteNumberException e)
catch (IndexOutOfRangeException)
{
DepictInfo = e.Message;
DepictInfo = string.Format(cultureInfo, "正在试图执行越界访问,请通过菜单栏<帮助>报告问题!");
}
catch (ObjectDisposedException)
{
DepictInfo = string.Format(cultureInfo, "正在对已释放的对象执行操作,请通过菜单栏<帮助>报告问题!");
}
catch (NotFiniteNumberException e)
{
DepictInfo = e.Message;
}
}
#endregion

Expand Down Expand Up @@ -912,17 +916,21 @@ await SerialPortBase.BaseStream.WriteAsync(SerialPortBase.Encoding.GetBytes(file
{
DepictInfo = e.Message;
}
catch(IndexOutOfRangeException)
catch (IndexOutOfRangeException)
{
DepictInfo = string.Format(cultureInfo, "正在试图执行越界访问,请通过菜单栏<帮助>报告问题!");
}
catch(NotFiniteNumberException e)
catch(ObjectDisposedException)
{
DepictInfo = string.Format(cultureInfo, "正在对已释放的对象执行操作,请通过菜单栏<帮助>报告问题!");
}
catch (NotFiniteNumberException e)
{
DepictInfo = e.Message;
}
catch(ObjectDisposedException)
catch (InvalidOperationException e)
{
DepictInfo = string.Format(cultureInfo, "正在对已释放的对象执行操作,请通过菜单栏<帮助>报告问题!");
DepictInfo = e.Message;
}
}
#endregion
Expand Down

0 comments on commit cd05d80

Please sign in to comment.