17 lines
516 B
C#
17 lines
516 B
C#
using System.Net.Http;
|
|
using System.Threading.Tasks;
|
|
using Novaloop.PaymoApi.Exceptions;
|
|
|
|
namespace Novaloop.PaymoApi.Extensions
|
|
{
|
|
internal static class HttpResponseMessageExtensions
|
|
{
|
|
internal static async Task ThrowExceptionWithDetailsIfUnsuccessful(this HttpResponseMessage response)
|
|
{
|
|
if (!response.IsSuccessStatusCode)
|
|
{
|
|
throw new ApiException((int) response.StatusCode, await response.Content.ReadAsStringAsync());
|
|
}
|
|
}
|
|
}
|
|
} |