microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
affd7569cfa8bd4a83b86066b8636721ea186364

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.Common/Http/HttpException.cs

33lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4using System.Net;
5using System.Net.Http.Headers;
6using System.Text.Json;
7using System.Text.Json.Serialization;
8
9namespace Microsoft.Teams.Common.Http;
10
11public 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 {
20 return JsonSerializer.Serialize(new
21 {
22 headers = Headers,
23 statusCode = StatusCode,
24 body = Body
25 }, new JsonSerializerOptions()
26 {
27 WriteIndented = true,
28 IndentSize = 4,
29 DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
30 PropertyNamingPolicy = JsonNamingPolicy.CamelCase
31 });
32 }
33}