forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestErrorHandler.cs
More file actions
24 lines (21 loc) · 1020 Bytes
/
Copy pathRestErrorHandler.cs
File metadata and controls
24 lines (21 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System.Management.Automation;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.PowerShell.Cmdlets.WebPubSub.Models;
namespace Microsoft.Azure.PowerShell.Cmdlets.WebPubSub
{
internal static class CmdletRestExtension
{
public static void WriteError(this Cmdlet cmdlet, HttpResponseMessage responseMessage, Task<IErrorResponse> errorResponseTask, ref Task<bool> returnNow)
{
var errorString = responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
cmdlet.WriteError(new ErrorRecord(new System.Exception(), null, ErrorCategory.InvalidOperation, null)
{
ErrorDetails = new ErrorDetails(errorString) { RecommendedAction = string.Empty }
});
returnNow = Task.FromResult(true);
}
}
}