/// <summary> /// Generates a human-readable message for the user from a OneDriveException. /// </summary> /// <param name="ex">The Exception</param> /// <returns>A human-readable message</returns> public static string MessageForException(OneDriveException ex) { /* * * See also https://dev.onedrive.com/misc/errors.htm * * public enum OneDriveErrorCode * { * AccessDenied = 0, * ActivityLimitReached = 1, * AuthenticationCancelled = 2, * AuthenticationFailure = 3, * GeneralException = 4, * InvalidRange = 5, * InvalidRequest = 6, * ItemNotFound = 7, * MalwareDetected = 8, * MyFilesCapabilityNotFound = 9, * NameAlreadyExists = 10, * NotAllowed = 11, * NotSupported = 12, * ResourceModified = 13, * ResyncRequired = 14, * ServiceNotAvailable = 15, * Timeout = 16, * TooManyRedirects = 17, * QuotaLimitReached = 18, * Unauthenticated = 19, * UserDoesNotHaveMyFilesService = 20 * } */ if (ex == null) { return(string.Empty); } if (ex.IsMatch(OneDriveErrorCode.AccessDenied.ToString()) || ex.IsMatch(OneDriveErrorCode.AuthenticationCancelled.ToString()) || ex.IsMatch(OneDriveErrorCode.AuthenticationFailure.ToString()) || ex.IsMatch(OneDriveErrorCode.Unauthenticated.ToString())) { return(Branding.ReBrand(Resources.LocalizedText.OneDriveBadAuth)); } else if (ex.IsMatch(OneDriveErrorCode.QuotaLimitReached.ToString())) { return(Resources.LocalizedText.OneDriveErrorOutOfSpace); } else if (ex.IsMatch(OneDriveErrorCode.Timeout.ToString()) || ex.IsMatch(OneDriveErrorCode.ServiceNotAvailable.ToString())) { return(Resources.LocalizedText.OneDriveCantReachService); } else { return(ex.Message); } }
private MessageDialog GetOneDriveErrorMessageDialog(OneDriveException exception) { string error = ResourceLoader.GetForCurrentView().GetString("OneDriveError" + exception.Error.Code); if (string.IsNullOrWhiteSpace(error)) { error = string.Format("{0} ({1})", ResourceLoader.GetForCurrentView().GetString("OneDriveErrorUnknown"), exception.Error.Code); if (exception.Error.InnerError != null) { error += string.Format(" ({1})", exception.Error.InnerError.Code); } } string message = string.Format("{0}:{1}{2}", ResourceLoader.GetForCurrentView().GetString("CloudSynchronizationOneDriveErrorMessage"), Environment.NewLine, error); MessageDialog dialog = new MessageDialog(message, ResourceLoader.GetForCurrentView().GetString("CloudSynchronizationOneDriveErrorTitle")); return(dialog); }
public static bool IsMatchCode(this OneDriveException ex, OneDriveErrorCode code) { return(ex.IsMatch(code.ToString())); }