@@ -373,38 +373,48 @@ private static void CheckForErrors(RestResponseBase response)
373
373
throw new FossologyApiException ( ErrorCode . Unauthorized , response . StatusCode ) ;
374
374
} // if
375
375
376
- var forceError = false ;
376
+ FossologyApiException exception ;
377
377
try
378
378
{
379
379
if ( string . IsNullOrEmpty ( response . Content ) )
380
380
{
381
- throw new FossologyApiException (
381
+ exception = new FossologyApiException (
382
382
ErrorCode . RestApiError , response . StatusCode , string . Empty , null ) ;
383
- } // if
384
-
385
- if ( response . Content . ToLower ( ) . StartsWith ( "<html>" ) )
386
- {
387
- throw new FossologyApiException (
388
- ErrorCode . RestApiError , response . StatusCode , response . Content , null ) ;
389
- } // if
390
-
391
- var result = Newtonsoft . Json . JsonConvert . DeserializeObject < Result > ( response . Content ) ;
392
- if ( result != null )
383
+ }
384
+ else
393
385
{
394
- throw new FossologyApiException (
395
- ErrorCode . RestApiError , ( HttpStatusCode ) result . Code , result . Message , null ) ;
386
+ if ( response . Content . ToLower ( ) . StartsWith ( "<html>" ) )
387
+ {
388
+ exception = new FossologyApiException (
389
+ ErrorCode . RestApiError , response . StatusCode , response . Content , null ) ;
390
+ }
391
+ else
392
+ {
393
+ var result = Newtonsoft . Json . JsonConvert . DeserializeObject < Result > ( response . Content ) ;
394
+ if ( result != null )
395
+ {
396
+ exception = new FossologyApiException (
397
+ ErrorCode . RestApiError , ( HttpStatusCode ) result . Code , result . Message , null ) ;
398
+ }
399
+ else
400
+ {
401
+ exception = new FossologyApiException (
402
+ ErrorCode . RestApiError ,
403
+ response . StatusCode ,
404
+ "Unable to decode JSON response" ,
405
+ null ) ;
406
+ } // if
407
+ } // if
396
408
} // if
397
-
398
- Log . Warn ( "Unable to decode JSON response" ) ;
399
409
}
400
410
catch
401
411
{
402
- forceError = true ;
412
+ exception = new FossologyApiException ( ErrorCode . RestApiError ) ;
403
413
} // catch
404
414
405
- if ( forceError )
415
+ if ( exception != null )
406
416
{
407
- throw new FossologyApiException ( ErrorCode . RestApiError ) ;
417
+ throw exception ;
408
418
} // if
409
419
} // CheckForErrors()
410
420
0 commit comments