mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Use the OperationCancellationException to replace the StoppingException in 'ConvertToJson' (#8920)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user