public static bool IsProblemTableDoesNotExist(this global::Azure.RequestFailedException exception) { return(exception.ParseExtendedErrorInformation( (errorCode, message) => { if (errorCode == ExtendedErrorInformationCodes.TableNotFound) { return true; } if (errorCode == ExtendedErrorInformationCodes.BlobNotFound) { return true; } return ExtendedErrorCodeNotProvided(); }, () => ExtendedErrorCodeNotProvided())); bool ExtendedErrorCodeNotProvided() { if (exception.InnerException is System.Net.WebException) { var webEx = (System.Net.WebException)exception.InnerException; if (webEx.Response is System.Net.HttpWebResponse) { var httpResponse = (System.Net.HttpWebResponse)webEx.Response; return(httpResponse.StatusCode == System.Net.HttpStatusCode.NotFound); } } return(false); } }
public static TResult ParseStorageException <TResult>(this global::Azure.RequestFailedException storageException, Func <ExtendedErrorInformationCodes, string, TResult> onParsed, Func <TResult> onUnableToParse) { return(storageException.ParseExtendedErrorInformation( onParsed, () => { if (storageException.IsProblemTimeout()) { return onParsed(ExtendedErrorInformationCodes.Timeout, "The request to AST timed out."); } if (storageException.InnerException is System.Net.WebException) { var webEx = storageException.InnerException as System.Net.WebException; if (webEx.Response is System.Net.HttpWebResponse) { var httpWebResponse = webEx.Response as System.Net.HttpWebResponse; try { var responseContent = webEx.Message; // await httpWebResponse.GetResponseStream().ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine($"AST replied:{responseContent}"); return onParsed(ExtendedErrorInformationCodes.General, responseContent); } catch (Exception exFromStream) { exFromStream.GetType(); // Suppress warning return onUnableToParse(); } } } return onUnableToParse(); })); }
public static bool IsProblemDoesNotExist(this global::Azure.RequestFailedException exception) { return(exception.ParseExtendedErrorInformation( (errorCode, message) => { if (errorCode == ExtendedErrorInformationCodes.TableNotFound) { return true; } if (errorCode == ExtendedErrorInformationCodes.BlobNotFound) { return true; } if (errorCode == ExtendedErrorInformationCodes.Other) { if ("ContainerNotFound".Equals(exception.ErrorCode, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; }, () => { if (exception.GetHttpStatusCode() == HttpStatusCode.NotFound) { return true; } if (exception.InnerException is System.Net.WebException) { var webEx = (System.Net.WebException)exception.InnerException; if (webEx.Response is System.Net.HttpWebResponse) { var httpResponse = (System.Net.HttpWebResponse)webEx.Response; return (httpResponse.StatusCode == System.Net.HttpStatusCode.NotFound); } } return false; })); }
public static bool IsProblemResourceAlreadyExists(this global::Azure.RequestFailedException exception) { return(exception.ParseExtendedErrorInformation( (errorCode, errorMessage) => errorCode == ExtendedErrorInformationCodes.EntityAlreadyExists, () => false)); }
public static bool IsProblemPropertyValueTooLarge(this global::Azure.RequestFailedException exception) { return(exception.ParseExtendedErrorInformation( (errorCode, errorMessage) => errorCode == ExtendedErrorInformationCodes.PropertyValueTooLarge, () => false)); }