handle bad requests better (don't fail when connection not available)
Don't crash when writing log to protected directory.
This commit is contained in:
parent
ab0f591773
commit
7d8dff4040
5 changed files with 32 additions and 5 deletions
|
|
@ -320,9 +320,9 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public enum ReportSeverity2 { Warning, Error }
|
||||
|
||||
public void ReportException(Exception e, string key, string value, ReportSeverity2 warningLevel = ReportSeverity2.Warning)
|
||||
public void ReportException(Exception e, string key = "", string value = "", ReportSeverity2 warningLevel = ReportSeverity2.Warning)
|
||||
{
|
||||
// do nothing
|
||||
_raygunClient.Send(e);
|
||||
}
|
||||
|
||||
private event EventHandler unregisterEvent;
|
||||
|
|
|
|||
|
|
@ -214,6 +214,9 @@ namespace MatterHackers.MatterControl
|
|||
base.OnDraw(graphics2D);
|
||||
}
|
||||
|
||||
readonly static string writeFaildeWaring = "WARNING: Write Failed!".Localize();
|
||||
readonly static string cantAccessPath = "Can't access '{0}'.".Localize();
|
||||
|
||||
private void onExportLogFileSelected(SaveFileDialogParams saveParams)
|
||||
{
|
||||
if (saveParams.FileName != null)
|
||||
|
|
@ -221,7 +224,17 @@ namespace MatterHackers.MatterControl
|
|||
string filePathToSave = saveParams.FileName;
|
||||
if (filePathToSave != null && filePathToSave != "")
|
||||
{
|
||||
textScrollWidget.WriteToFile(filePathToSave);
|
||||
try
|
||||
{
|
||||
textScrollWidget.WriteToFile(filePathToSave);
|
||||
}
|
||||
catch(UnauthorizedAccessException e)
|
||||
{
|
||||
PrinterOutputCache.Instance.PrinterLines.Add("");
|
||||
PrinterOutputCache.Instance.PrinterLines.Add(writeFaildeWaring);
|
||||
PrinterOutputCache.Instance.PrinterLines.Add(cantAccessPath.FormatWith(filePathToSave));
|
||||
PrinterOutputCache.Instance.PrinterLines.Add("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3274,3 +3274,9 @@ Translated:More
|
|||
English:Share
|
||||
Translated:Share
|
||||
|
||||
English:WARNING: Write Failed!
|
||||
Translated:WARNING: Write Failed!
|
||||
|
||||
English:Can't access '{0}'.
|
||||
Translated:Can't access '{0}'.
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 20587cdd3be05b85d1cee98b19d19be3638960ae
|
||||
Subproject commit c70c78502dd2dcf313f3b3d6dd5d793f0760eec0
|
||||
|
|
@ -153,6 +153,14 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
Console.WriteLine("Web exception occurred. Status code: {0}", ex.Status);
|
||||
}
|
||||
catch (IOException ioException)
|
||||
{
|
||||
Console.WriteLine("Web exception occurred. Message: {0}", ioException.Message);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MatterControlApplication.Instance.ReportException(e);
|
||||
}
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
|
@ -161,7 +169,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
if (request == null)
|
||||
{
|
||||
throw new ArgumentNullException("request");
|
||||
return null;
|
||||
}
|
||||
HttpWebResponse response = null;
|
||||
try
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue