Skip to content

Commit 0e5da15

Browse files
committed
Merge branch '5601-regenerate-sdk' of github.com:watson-developer-cloud/dotnet-standard-sdk into 5601-regenerate-sdk
2 parents 604d349 + 3a1058b commit 0e5da15

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/IBM.WatsonDeveloperCloud/Http/Filters/ErrorFilter.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*
1616
*/
1717

18+
using System.Collections.Generic;
1819
using System.Net.Http;
20+
using System.Net.Http.Headers;
1921
using IBM.WatsonDeveloperCloud.Http.Exceptions;
2022
using Newtonsoft.Json;
2123

@@ -29,8 +31,24 @@ public void OnResponse(IResponse response, HttpResponseMessage responseMessage)
2931
{
3032
if (!responseMessage.IsSuccessStatusCode)
3133
{
34+
HttpHeaders responseHeaders = responseMessage.Headers;
35+
36+
IEnumerable<string> globalTransactionId;
37+
string globalTransactionIdString = "";
38+
if (responseHeaders.TryGetValues("x-global-transaction-id", out globalTransactionId))
39+
{
40+
globalTransactionIdString = string.Join(", ", globalTransactionId);
41+
}
42+
43+
IEnumerable<string> watsonTransactionId;
44+
string watsonTransactionIdString = "";
45+
if (responseHeaders.TryGetValues("X-DP-Watson-Tran-ID", out watsonTransactionId))
46+
{
47+
watsonTransactionIdString = string.Join(", ", watsonTransactionId);
48+
}
49+
3250
ServiceResponseException exception =
33-
new ServiceResponseException(response, responseMessage, $"The API query failed with status code {responseMessage.StatusCode}: {responseMessage.ReasonPhrase}");
51+
new ServiceResponseException(response, responseMessage, $"The API query failed with status code {responseMessage.StatusCode}: {responseMessage.ReasonPhrase} | x-global-transaction-id: {globalTransactionIdString} | X-DP-Watson-Tran-ID: {watsonTransactionIdString}");
3452

3553
var error = responseMessage.Content.ReadAsStringAsync().Result;
3654

0 commit comments

Comments
 (0)