From 01a2d97212d7b0d45b4972a8ba5498db4465f86e Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Mon, 16 Jan 2017 08:13:00 -0500 Subject: [PATCH] Update ApiErrorMessageSafe to return null for empty and whitespace strings (#1540) * return null if ApiError.Message is empty or whitespace * Uncomment test, which now passes --- Octokit.Tests/Http/ConnectionTests.cs | 2 +- Octokit/Exceptions/ApiException.cs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests/Http/ConnectionTests.cs b/Octokit.Tests/Http/ConnectionTests.cs index e280bfa0..f6c0618e 100644 --- a/Octokit.Tests/Http/ConnectionTests.cs +++ b/Octokit.Tests/Http/ConnectionTests.cs @@ -349,7 +349,7 @@ namespace Octokit.Tests.Http Assert.Equal(45, exception.RetryAfterSeconds); } - [Fact(Skip = "Fails due to https://github.com/octokit/octokit.net/issues/1529. The message is empty but the default message isn't displayed. However, this isn't due to the introduction of AbuseException, but rather something else.")] + [Fact] public async Task ThrowsAbuseExceptionWithDefaultMessageForUnsafeAbuseResponse() { string messageText = string.Empty; diff --git a/Octokit/Exceptions/ApiException.cs b/Octokit/Exceptions/ApiException.cs index d68d8591..67b16735 100644 --- a/Octokit/Exceptions/ApiException.cs +++ b/Octokit/Exceptions/ApiException.cs @@ -178,7 +178,12 @@ namespace Octokit { get { - return ApiError != null ? ApiError.Message : null; + if (ApiError != null && !string.IsNullOrWhiteSpace(ApiError.Message)) + { + return ApiError.Message; + } + + return null; } }