microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Common/Http/HttpException.cs
28lines · modecode
| 1 | using System.Net; |
| 2 | using System.Net.Http.Headers; |
| 3 | using System.Text.Json; |
| 4 | using System.Text.Json.Serialization; |
| 5 | |
| 6 | namespace Microsoft.Teams.Common.Http; |
| 7 | |
| 8 | public class HttpException : Exception |
| 9 | { |
| 10 | public required HttpResponseHeaders Headers { get; set; } |
| 11 | public required HttpStatusCode StatusCode { get; set; } |
| 12 | public HttpRequestMessage? Request { get; set; } |
| 13 | public object? Body { get; set; } |
| 14 | |
| 15 | public override string ToString() |
| 16 | { |
| 17 | if (Body is string textBody) |
| 18 | { |
| 19 | return textBody; |
| 20 | } |
| 21 | |
| 22 | return JsonSerializer.Serialize(Body, new JsonSerializerOptions() |
| 23 | { |
| 24 | WriteIndented = true, |
| 25 | DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull |
| 26 | }); |
| 27 | } |
| 28 | } |