|
1 | 1 | // ---------------------------------------------------------------------------
|
2 | 2 | // <copyright file="RestApi.cs" company="Tethys">
|
3 |
| -// Copyright (C) 2019-2020 T. Graf |
| 3 | +// Copyright (C) 2019-2022 T. Graf |
4 | 4 | // </copyright>
|
5 | 5 | //
|
6 | 6 | // Licensed under the MIT License.
|
@@ -348,9 +348,22 @@ private static void CheckForErrors(IRestResponse response)
|
348 | 348 | FossologyApiException exception;
|
349 | 349 | try
|
350 | 350 | {
|
351 |
| - var result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result>(response.Content); |
352 |
| - exception = new FossologyApiException( |
353 |
| - ErrorCode.RestApiError, (HttpStatusCode)result.Code, result.Message, null); |
| 351 | + if (string.IsNullOrEmpty(response.Content)) |
| 352 | + { |
| 353 | + exception = new FossologyApiException( |
| 354 | + ErrorCode.RestApiError, response.StatusCode, string.Empty, null); |
| 355 | + } |
| 356 | + else if (response.Content.ToLower().StartsWith("<html>")) |
| 357 | + { |
| 358 | + exception = new FossologyApiException( |
| 359 | + ErrorCode.RestApiError, response.StatusCode, response.Content, null); |
| 360 | + } |
| 361 | + else |
| 362 | + { |
| 363 | + var result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result>(response.Content); |
| 364 | + exception = new FossologyApiException( |
| 365 | + ErrorCode.RestApiError, (HttpStatusCode)result.Code, result.Message, null); |
| 366 | + } // if |
354 | 367 | }
|
355 | 368 | catch
|
356 | 369 | {
|
|
0 commit comments