Skip to content

Commit 23cde55

Browse files
Merge pull request #97 from microsoftgraph/revert-80-exposeResponseHeadersInException
Revert "Provided pass through of response headers and status code for excepti…"
2 parents 6a05b6e + 60e8b3b commit 23cde55

File tree

3 files changed

+1
-49
lines changed

3 files changed

+1
-49
lines changed

src/Microsoft.Graph.Core/Exceptions/ServiceException.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Microsoft.Graph
66
{
77
using System;
8-
using System.Collections.Generic;
98

109
public class ServiceException : Exception
1110
{
@@ -17,11 +16,6 @@ public ServiceException(Error error, Exception innerException = null)
1716

1817
public Error Error { get; private set; }
1918

20-
// ResponseHeaders and StatusCode exposed as pass-through.
21-
public System.Net.Http.Headers.HttpResponseHeaders ResponseHeaders { get; internal set; }
22-
23-
public System.Net.HttpStatusCode StatusCode { get; internal set; }
24-
2519
public bool IsMatch(string errorCode)
2620
{
2721
if (string.IsNullOrEmpty(errorCode))

src/Microsoft.Graph.Core/Requests/HttpProvider.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,8 @@ public async Task<HttpResponseMessage> SendAsync(
203203
error.ThrowSite = throwsiteValues.FirstOrDefault();
204204
}
205205
}
206-
207-
throw new ServiceException(error)
208-
{
209-
// Pass through the response headers to the ServiceException.
210-
ResponseHeaders = response.Headers,
211206

212-
// Pass through the HTTP status code.
213-
StatusCode = response.StatusCode
214-
};
207+
throw new ServiceException(error);
215208
}
216209
}
217210

tests/Microsoft.Graph.Test/Requests/Functional/MailTests.cs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,7 @@ namespace Microsoft.Graph.Test.Requests.Functional
1010
[TestClass]
1111
public class MailTests : GraphTestBase
1212
{
13-
[Ignore] // Setup Fiddler autoresponder
14-
[TestMethod]
15-
public async Task MailGetGroupWithThrottlingError()
16-
{
17-
try
18-
{
19-
// All requests should have a client-request-id set so that the client can correlate a
20-
// request with a response.
21-
var headerOptions = new List<HeaderOption>()
22-
{
23-
new HeaderOption("client-request-id", new Guid("dddddddd-dddd-dddd-dddd-dddddddddddd").ToString())
24-
};
25-
26-
// To get a throttling error, I mocked up a 429 response in a text file and turned on the Fiddler
27-
// autoresponder to return the text file as the response envelope. The autoresponder for this
28-
// scenario responds to EXACT:https://graph.microsoft.com/v1.0/groups/036bd54c-c6e5-43eb-b8b5-03e019e75bd1
29-
var group = await graphClient.Groups["036bd54c-c6e5-43eb-b8b5-03e019e75bd1"].Request(headerOptions).GetAsync();
30-
}
31-
catch (Microsoft.Graph.ServiceException e)
32-
{
33-
if ((int)e.StatusCode == 429) // Too Many Requests
34-
{
35-
// We have the client-request-id for correlating the response to the request that failed.
36-
IEnumerable<string> clientrequestidvalues;
37-
Assert.IsTrue(e.ResponseHeaders.TryGetValues("client-request-id", out clientrequestidvalues));
3813

39-
// We have the Retry-After that the client can use to wait and resubmit the rejected request.
40-
IEnumerable<string> retryaftervalues;
41-
Assert.IsTrue(e.ResponseHeaders.TryGetValues("Retry-After", out retryaftervalues));
42-
}
43-
else
44-
{
45-
Assert.Fail("Something happened, check out a trace. Error code: {0}", e.Error.Code);
46-
}
47-
}
48-
}
4914

5015
public async Task<Message> createEmail(string emailBody)
5116
{

0 commit comments

Comments
 (0)