Don't catch OperationCanceledExceptions

Fix IRC connect always returning true
This commit is contained in:
Cyberboss
2018-09-27 15:16:38 -04:00
parent 10fdffb128
commit 8a35f87d35
12 changed files with 56 additions and 1 deletions
@@ -65,6 +65,10 @@ namespace Tgstation.Server.Host.Components.Byond
{
await ioManager.DeleteDirectory(ByondCachePath, cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
logger.LogWarning("Error deleting BYOND cache! Exception: {0}", e);
@@ -92,6 +92,10 @@ namespace Tgstation.Server.Host.Components.Byond
{
await ioManager.DeleteDirectory(ioManager.ConcatPath(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "byond/cache"), cancellationToken).ConfigureAwait(false);
}
catch(OperationCanceledException)
{
throw;
}
catch (Exception e)
{
logger.LogWarning("Error deleting BYOND cache! Exception: {0}", e);
@@ -305,6 +305,10 @@ namespace Tgstation.Server.Host.Components.Chat
if (result != null)
await SendMessage(result, new List<ulong> { message.User.Channel.RealId }, cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
//error bc custom commands should reply about why it failed
@@ -82,6 +82,10 @@ namespace Tgstation.Server.Host.Components.Chat
return result;
}
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
logger.LogWarning("Error retrieving custom commands! Exception: {0}", e);
@@ -128,6 +128,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
using (cancellationToken.Register(() => channelsAvailable.SetCanceled()))
await channelsAvailable.Task.ConfigureAwait(false);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
logger.LogWarning("Error connecting to Discord: {0}", e);
@@ -148,6 +152,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
cancellationToken.ThrowIfCancellationRequested();
await client.LogoutAsync().ConfigureAwait(false);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
logger.LogWarning("Error disconnecting from discord: {0}", e);
@@ -204,6 +212,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
CancelToken = cancellationToken
}) ?? Task.CompletedTask).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
logger.LogWarning("Error sending discord message: {0}", e);
@@ -304,9 +304,14 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
client.Listen();
}, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
logger.LogWarning("Unable to connect to IRC: {0}", e);
return false;
}
return true;
}, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current);
@@ -332,6 +337,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
Dispose();
await listenTask.ConfigureAwait(false);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
logger.LogWarning("Error disconnecting from IRC! Exception: {0}", e);
@@ -264,6 +264,10 @@ namespace Tgstation.Server.Host.Components.Compiler
++deleting;
await ioManager.DeleteDirectory(x, cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
logger.LogWarning("Error deleting directory {0}! Exception: {1}", x, e);
@@ -121,6 +121,7 @@ namespace Tgstation.Server.Host.Components.Interop
await (handler?.HandleInterop(command, cancellationToken) ?? Task.CompletedTask).ConfigureAwait(false);
}
catch (OperationCanceledException) { }
catch (Exception ex)
{
logger.LogDebug("Exception while trying to handle command json write: {0}", ex);
@@ -429,6 +429,10 @@ namespace Tgstation.Server.Host.Components.Watchdog
commandString,
cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
logger.LogInformation("Send command exception:{0}{1}", Environment.NewLine, e.Message);
@@ -623,6 +623,10 @@ namespace Tgstation.Server.Host.Components.Watchdog
monitorState = new MonitorState(); //clean the slate and continue
}
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
launchException = e;
@@ -332,7 +332,8 @@ namespace Tgstation.Server.Host.Controllers
}
catch (Exception e)
{
Logger.LogError("Error changing instance online state! Exception: {0}", e);
if(!(e is OperationCanceledException))
Logger.LogError("Error changing instance online state! Exception: {0}", e);
originalModel.Online = originalOnline;
originalModel.DreamDaemonSettings.AutoStart = oldAutoStart;
if (originalModelPath != null)
@@ -62,6 +62,10 @@ namespace Tgstation.Server.Host.Security
principal = UserPrincipal.FindByIdentity(pc, user.SystemIdentifier);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
logger.LogWarning("Error loading user for context type {0}! Exception: {1}", contextType, e);