mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -07:00
Added something to show errors during async code, which is used in the JIRA Plugin.
This commit is contained in:
parent
e08985fd6f
commit
7599766e3a
1 changed files with 18 additions and 0 deletions
|
@ -25,6 +25,8 @@ using Greenshot.Plugin;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Dapplo.Log;
|
using Dapplo.Log;
|
||||||
|
using Greenshot.Forms;
|
||||||
|
using Greenshot.Helpers;
|
||||||
using GreenshotJiraPlugin.Forms;
|
using GreenshotJiraPlugin.Forms;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
@ -57,6 +59,22 @@ namespace GreenshotJiraPlugin {
|
||||||
|
|
||||||
public JiraPlugin() {
|
public JiraPlugin() {
|
||||||
_instance = this;
|
_instance = this;
|
||||||
|
// Added to prevent Greenshot from shutting down when there was an exception in a Task
|
||||||
|
TaskScheduler.UnobservedTaskException += (sender, args) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Exception exceptionToLog = args.Exception;
|
||||||
|
string exceptionText = EnvironmentInfo.BuildReport(exceptionToLog);
|
||||||
|
Log.Error("Exception caught in the UnobservedTaskException handler.");
|
||||||
|
Log.Error(exceptionText);
|
||||||
|
new BugReportForm(exceptionText).ShowDialog();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
args.SetObserved();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IDestination> Destinations() {
|
public IEnumerable<IDestination> Destinations() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue