Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions WikiFunctions/ErrorHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public partial class ErrorHandler : Form
private static bool HandleKnownExceptions(Exception ex)
{
Tools.WriteDebug("HandleKnownExceptions", ex.StackTrace);
Exception exceptionOfInterest;
// invalid regex - only ArgumentException, without subclasses
if (ex is ArgumentException &&
(ex.StackTrace.Contains("System.Text.RegularExpressions") ||
Expand All @@ -58,10 +59,13 @@ private static bool HandleKnownExceptions(Exception ex)
"Unsupported culture");
}
// network access error
else if (ex is System.Net.WebException || ex.InnerException is System.Net.WebException)
else if ((exceptionOfInterest = ex) is System.Net.WebException ||
(exceptionOfInterest = ex.InnerException) is System.Net.WebException)
{
// if AWB starts up offline we'll hit here, so provide clear network related message
string msg = ex.Message.StartsWith(@"The type initializer for") ? ex.InnerException.Message : ex.Message;
string msg = exceptionOfInterest.Message;

if (exceptionOfInterest.HResult != 0)
msg += string.Format(" (HRESULT 0x{0:X})", exceptionOfInterest.HResult);

MessageBox.Show(msg, "Network access error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
Expand Down