microsoft/teams.net
Publicmirrored from https://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Common/Http/HttpException.cs
31lines · modeblame
82a4e3c3Rajan1 years ago | 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. | |
| 3 | | |
73e7847aAlex Acebo1 years ago | 4 | using System.Net; |
| 5 | using System.Net.Http.Headers; | |
| 6 | using System.Text.Json; | |
| 7 | using System.Text.Json.Serialization; | |
| 8 | | |
| 9 | namespace Microsoft.Teams.Common.Http; | |
| 10 | | |
| 11 | public class HttpException : Exception | |
| 12 | { | |
| 13 | public required HttpResponseHeaders Headers { get; set; } | |
| 14 | public required HttpStatusCode StatusCode { get; set; } | |
| 15 | public HttpRequestMessage? Request { get; set; } | |
| 16 | public object? Body { get; set; } | |
| 17 | | |
| 18 | public override string ToString() | |
| 19 | { | |
20d75721Kavin1 years ago | 20 | if (Body is string textBody) |
| 21 | { | |
| 22 | return textBody; | |
| 23 | } | |
| 24 | | |
73e7847aAlex Acebo1 years ago | 25 | return JsonSerializer.Serialize(Body, new JsonSerializerOptions() |
| 26 | { | |
| 27 | WriteIndented = true, | |
| 28 | DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull | |
| 29 | }); | |
| 30 | } | |
| 31 | } |