Azure / azure-notificationhubs-dotnet

.NET SDK for Azure Notification Hubs
MIT License
70 stars 119 forks source link

[BUG] BadRequest parsing doesn't include rationale when response is JSON #196

Open marstr opened 3 years ago

marstr commented 3 years ago

Describe the bug After a customer compliant, I briefly inspected our exception handling code in this library. When a client receives a Bad Request (HTTP 400), it will get processed here: https://github.com/Azure/azure-notificationhubs-dotnet/blob/da468dfaaf072f0ef2fd17389f61e504f732edb7/src/Microsoft.Azure.NotificationHubs/ExceptionUtility.cs#L42

which in turn attempts to process it as XML here:

https://github.com/Azure/azure-notificationhubs-dotnet/blob/da468dfaaf072f0ef2fd17389f61e504f732edb7/src/Microsoft.Azure.NotificationHubs/ExceptionUtility.cs#L106

However, JSON responses occasionally get processed by this code, and can ultimately strip out key-hints (like "certificate is expired") that would be included in the exception's default message.

To Reproduce