捕获异常, 写出日志

This commit is contained in:
liufei
2022-01-09 17:33:49 +08:00
parent fdd8c8bb10
commit 145564bfc5
5 changed files with 35 additions and 52 deletions

View File

@@ -202,8 +202,9 @@ namespace GeekDesk.Util
return bm;
}
}
catch (Exception)
catch (Exception ex)
{
LogUtil.WriteErrorLog(ex, "获取缩略图失败!filePath=" + filePath);
return Base64ToBitmapImage(Constants.DEFAULT_IMG_IMAGE_BASE64);
}
@@ -302,8 +303,9 @@ namespace GeekDesk.Util
ms.Close();
return Convert.ToBase64String(arr);
}
catch (Exception)
catch (Exception ex)
{
LogUtil.WriteErrorLog(ex, "文件转base64失败!Imagefilename=" + Imagefilename);
return null;
}
}

View File

@@ -48,10 +48,9 @@ namespace GeekDesk.Util
key.Close();
}
#pragma warning disable CS0168 // 声明了变量“ex”但从未使用过
catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”但从未使用过
{
LogUtil.WriteErrorLog(ex, "设置开机/取消失败!started=" + started);
return false;
}
}
@@ -62,19 +61,17 @@ namespace GeekDesk.Util
key.DeleteValue(exeName);//取消开机启动
key.Close();
}
#pragma warning disable CS0168 // 声明了变量“ex”但从未使用过
catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”但从未使用过
{
LogUtil.WriteErrorLog(ex, "取消开机启动失败!started=" + started);
return false;
}
}
return true;
}
#pragma warning disable CS0168 // 声明了变量“ex”但从未使用过
catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”但从未使用过
{
LogUtil.WriteErrorLog(ex, "取消/开机/失败!started=" + started);
if (key != null)
{
key.Close();