コード例 #1
0
 public static ErrorRecord WriteErrorforBadrequest(ErrorResponseException ex)
 {
     if (ex != null && !string.IsNullOrEmpty(ex.Response.Content))
     {
         ErrorResponseContent errorExtract = new ErrorResponseContent();
         errorExtract = JsonConvert.DeserializeObject <ErrorResponseContent>(ex.Response.Content);
         if (!string.IsNullOrEmpty(errorExtract.error.message))
         {
             return(new ErrorRecord(ex, errorExtract.error.message, ErrorCategory.OpenError, ex));
         }
         else
         {
             return(new ErrorRecord(ex, ex.Response.Content, ErrorCategory.OpenError, ex));
         }
     }
     else
     {
         Exception emptyEx = new Exception("Response object empty");
         return(new ErrorRecord(emptyEx, "Response object was empty", ErrorCategory.OpenError, emptyEx));
     }
 }
コード例 #2
0
 public static bool CheckErrorforNotfound(ErrorResponseException ex)
 {
     if (ex != null && !string.IsNullOrEmpty(ex.Response.Content))
     {
         ErrorResponseContent errorExtract = new ErrorResponseContent();
         errorExtract = JsonConvert.DeserializeObject <ErrorResponseContent>(ex.Response.Content);
         if (errorExtract.error.message.ToLower().Contains("not found"))
         {
             return(false);
         }
         else
         {
             new ErrorRecord(ex, ex.Response.Content, ErrorCategory.OpenError, ex);
             return(true);
         }
     }
     else
     {
         Exception emptyEx = new Exception("Response object empty");
         new ErrorRecord(emptyEx, "Response object was empty", ErrorCategory.OpenError, emptyEx);
         return(true);
     }
 }