Use the OperationCancellationException to replace the StoppingException in 'ConvertToJson' (#8920)

This commit is contained in:
Dongbo Wang
2019-02-20 23:55:39 -08:00
committed by GitHub
parent 2c488fb4e5
commit 8617363089
2 changed files with 3 additions and 12 deletions
@@ -104,13 +104,6 @@ namespace Microsoft.PowerShell.Commands
}
}
/// <summary>
/// Exception used for cancellation.
/// </summary>
private class StoppingException : System.Exception
{
}
#endregion HelperTypes
#region ConvertFromJson
@@ -483,7 +476,7 @@ namespace Microsoft.PowerShell.Commands
return JsonConvert.SerializeObject(preprocessedObject, jsonSettings);
}
catch (StoppingException)
catch (OperationCanceledException)
{
return null;
}
@@ -500,10 +493,7 @@ namespace Microsoft.PowerShell.Commands
/// <returns>An object suitable for serializing to JSON.</returns>
private static object ProcessValue(object obj, int currentDepth, in ConvertToJsonContext context)
{
if (context.CancellationToken.IsCancellationRequested)
{
throw new StoppingException();
}
context.CancellationToken.ThrowIfCancellationRequested();
PSObject pso = obj as PSObject;
@@ -6714,6 +6714,7 @@ namespace Microsoft.PowerShell
null,
ExtendedTypeSystem.InvalidCastException,
sourceValue,
typeof(PSObject),
destinationType);
}