Skip to content

Commit

Permalink
Fix Unhandled Error if skyd file can't be read when showing Protein t…
Browse files Browse the repository at this point in the history
…ooltip (#2740)

Fixed Unhandled Error hovering over Protein in Targets tree if .skyd file cannot be read (reported on Exception Web)
  • Loading branch information
nickshulman authored Oct 28, 2023
1 parent 51da604 commit 53ce871
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 8 deletions.
2 changes: 2 additions & 0 deletions pwiz_tools/Shared/CommonUtil/SystemUtil/ParallelEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ private static void LoopWithExceptionHandling(Action loop, Action<AggregateExcep
throw new IOException(ex.Message, ex);
if (ex is OperationCanceledException)
throw new OperationCanceledException(ex.Message, ex);
if (ex is UnauthorizedAccessException)
throw new UnauthorizedAccessException(ex.Message, ex);
throw new TargetInvocationException(ex.Message, ex);
}
if (catchClause != null)
Expand Down
11 changes: 11 additions & 0 deletions pwiz_tools/Skyline/Controls/SeqNode/SrmTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,18 @@ private void Timer_Tick(Object sender, EventArgs e)
_timer.Stop();
if (_tipDisplayer == null || !_tipDisplayer.AllowDisplayTip)
return;
try
{
DisplayTip();
}
catch (Exception exception)
{
ExceptionUtil.DisplayOrReportException(this, exception, Resources.NodeTip_Timer_Tick_An_error_occurred_displaying_a_tooltip_);
}
}

private void DisplayTip()
{
Rectangle rectScreen = _tipDisplayer.ScreenRect;
AnimateMode animate = AnimateMode.SlideTopToBottom;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1345,14 +1345,7 @@ private bool CheckForErrors(bool silentSuccess, bool needsCheck)
}
catch (Exception exception)
{
if (ExceptionUtil.IsProgrammingDefect(exception))
{
Program.ReportException(exception);
}
else
{
MessageDlg.ShowWithException(this, exception.Message, exception);
}
ExceptionUtil.DisplayOrReportException(this, exception);
Assume.IsTrue(errorCheckCanceled);
}
}
Expand Down
9 changes: 9 additions & 0 deletions pwiz_tools/Skyline/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pwiz_tools/Skyline/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -13878,6 +13878,9 @@ If you choose Disable, you can enable Auto-select later with the "Refine &gt; Ad
<data name="Server_GetKey___anonymous_" xml:space="preserve">
<value> (anonymous)</value>
</data>
<data name="NodeTip_Timer_Tick_An_error_occurred_displaying_a_tooltip_" xml:space="preserve">
<value>An error occurred displaying a tooltip.</value>
</data>
<data name="EncyclopeDiaHelpers_Generate_Waiting_for_chromatogram_library" xml:space="preserve">
<value>Waiting for chromatogram library</value>
</data>
Expand Down
28 changes: 28 additions & 0 deletions pwiz_tools/Skyline/Util/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using System.Threading;
using System.Windows.Forms;
using pwiz.Common.SystemUtil;
using pwiz.Skyline.Alerts;
using pwiz.Skyline.FileUI;
using pwiz.Skyline.Properties;
using pwiz.Skyline.SettingsUI;
Expand Down Expand Up @@ -1920,6 +1921,8 @@ public static void WrapAndThrowException(Exception x)
throw new IOException(x.Message, x);
if (x is OperationCanceledException)
throw new OperationCanceledException(x.Message, x);
if (x is UnauthorizedAccessException)
throw new UnauthorizedAccessException(x.Message, x);
throw new TargetInvocationException(x.Message, x);
}

Expand Down Expand Up @@ -2127,6 +2130,31 @@ public static bool IsProgrammingDefect(Exception exception)

return true;
}

/// <summary>
/// Calls either <see cref="MessageDlg.ShowWithException"/> or <see cref="Program.ReportException"/> depending
/// on what <see cref="IsProgrammingDefect"/> returns.
/// <param name="parent">Parent window for message dialog</param>
/// <param name="exception">The exception that was caught</param>
/// <param name="message">Optional message which summarizes what Skyline was trying to do when the exception happened,
/// to be inserted on a separate line before the exception's message.</param>
/// </summary>
public static void DisplayOrReportException(IWin32Window parent, Exception exception, string message = null)
{
if (IsProgrammingDefect(exception))
{
Program.ReportException(exception);
}
else
{
string fullMessage = exception.Message;
if (string.IsNullOrEmpty(message))
{
fullMessage = TextUtil.LineSeparate(message, fullMessage);
}
MessageDlg.ShowWithException(parent, fullMessage, exception);
}
}
}

public class Alarms
Expand Down

0 comments on commit 53ce871

Please sign in to comment.