microsoft/teams.net
Publicmirrored from https://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Common/Http/HttpException.cs
33lines · modeblame
82a4e3c3Rajan12 months 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 | { | |
b6c66549Alex Acebo6 months ago | 20 | return JsonSerializer.Serialize(new |
20d75721Kavin1 years ago | 21 | { |
b6c66549Alex Acebo6 months ago | 22 | headers = Headers, |
| 23 | statusCode = StatusCode, | |
| 24 | body = Body | |
| 25 | }, new JsonSerializerOptions() | |
73e7847aAlex Acebo1 years ago | 26 | { |
| 27 | WriteIndented = true, | |
b6c66549Alex Acebo6 months ago | 28 | IndentSize = 4, |
| 29 | DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, | |
| 30 | PropertyNamingPolicy = JsonNamingPolicy.CamelCase | |
73e7847aAlex Acebo1 years ago | 31 | }); |
| 32 | } | |
| 33 | } |