示例#1
0
 private void OnListFailed(DropboxException ex)
 {
     Dispatcher.BeginInvoke(() =>
                            MessageBox.Show(
                                DropBoxResources.ListError,
                                DropBoxResources.ListTitle,
                                MessageBoxButton.OK));
 }
示例#2
0
 private void ShowError(DropboxException dropboxException)
 {
     Dispatcher.BeginInvoke(() =>
                            MessageBox.Show(
                                DropBoxResources.GetTokenError,
                                "DropBox",
                                MessageBoxButton.OK));
 }
示例#3
0
        public void LogException(DropboxException exception)
        {
            if ((exception is DropboxRestException) && ((DropboxRestException)exception).StatusCode == HttpStatusCode.Unauthorized)
            {
                return;
            }

            Logger.LogExceptionSilently(exception);
        }
示例#4
0
 private void OnChunkedUploadFailure(DropboxException dropboxException)
 {
     _chunksFailed++;
     if (_lastChunkUploaded != null && _chunksFailed <= _maxRetries.GetValueOrDefault(DefaultMaxRetries))
     {
         OnChunkSuccess(_lastChunkUploaded);
     }
     else
     {
         _failure.Invoke(dropboxException);
     }
 }
示例#5
0
        public void LogException(DropboxException exception)
        {
            switch (exception.StatusCode)
            {
            case HttpStatusCode.Unauthorized:
                break;

            default:
                myLogger.LogExceptionSilently(exception);
                break;
            }
        }
示例#6
0
        private void Fail(DropboxException ex)
        {
            Found     = false;
            IsLoading = false;

            if (ex.StatusCode == HttpStatusCode.NotFound)
            {
                MessageBox.Show(Labels.ConnectionErrorMessage, Labels.ConnectionErrorTitle, MessageBoxButton.OK);
            }

            MessageBox.Show(Labels.GenericErrorMessage, Labels.ErrorTitle, MessageBoxButton.OK);
        }
示例#7
0
        private void OnFileDownloadFailed(DropboxException obj)
        {
            Dispatcher.BeginInvoke(() =>
            {
                progBusy.IsBusy = false;

                MessageBox.Show(
                    DropBoxResources.DownloadError,
                    DropBoxResources.ListTitle,
                    MessageBoxButton.OK);
            });
        }
示例#8
0
        public static ExitCode?HandleBadInputException(this DropboxException ex)
        {
            var badInputException = ex as BadInputException;

            if (badInputException == null)
            {
                return(null);
            }

            Console.WriteLine($"An error occurred: {badInputException}");

            return(ExitCode.BadArguments);
        }
示例#9
0
        public static ExitCode?HandleHttpException(this DropboxException ex)
        {
            var httpException = ex as HttpException;

            if (httpException == null)
            {
                return(null);
            }

            Console.WriteLine($"An HTTP error occurred: {httpException}");

            return(ExitCode.BadArguments);
        }
示例#10
0
        public static ExitCode?HandleAuthException(this DropboxException ex)
        {
            var authException = ex as AuthException;

            if (authException == null)
            {
                return(null);
            }

            Console.WriteLine($"An authentication error occurred: {authException}");

            return(ExitCode.AccessDenied);
        }
示例#11
0
        public static ExitCode?HandleRateLimitException(this DropboxException ex)
        {
            var rateLimitException = ex as RateLimitException;

            if (rateLimitException == null)
            {
                return(null);
            }

            Console.WriteLine($"A rate limit error occurred: {rateLimitException}");

            return(ExitCode.Canceled);
        }
示例#12
0
        void OnDownloadFailed(DropboxException ex)
        {
            Utilities.ShowProgressIndicator(false);

            switch (ex.StatusCode)
            {
            case HttpStatusCode.NotFound:
                MessageBox.Show(Labels.FileNotFoundShare, Labels.ErrorTitle, MessageBoxButton.OK);
                break;

            default:
                MessageBox.Show(ex.StatusCode.ToString());
                break;
            }
        }
示例#13
0
        private static ExitCode HandleDropboxException(DropboxException ex)
        {
            Console.WriteLine("An error occurred and your file was not uploaded.");

            var exitCode = ex.HandleAuthException()
                           ?? ex.HandleAccessException()
                           ?? ex.HandleRateLimitException()
                           ?? ex.HandleBadInputException()
                           ?? ex.HandleHttpException()
                           ?? ExitCode.UnknownError;

            if (exitCode == ExitCode.UnknownError)
            {
                Console.WriteLine(ex.Message);
            }

            return(exitCode);
        }
示例#14
0
        void OnFail(DropboxException ed)
        {
            Utilities.ShowProgressIndicator(false);
            Uploading = false;
            switch (ed.StatusCode)
            {
            case HttpStatusCode.NotFound:
            case HttpStatusCode.LengthRequired:
                MessageBox.Show(Labels.ConnectionErrorMessage, Labels.ConnectionErrorTitle, MessageBoxButton.OK);
                return;

            case HttpStatusCode.BadRequest:
                MessageBox.Show(Labels.FileExtensionError, Labels.ErrorTitle, MessageBoxButton.OK);
                return;
            }

            MessageBox.Show(Labels.GenericErrorMessage, Labels.ErrorTitle, MessageBoxButton.OK);
        }
示例#15
0
        private static ExitCode HandleException(DropboxException ex)
        {
            Console.WriteLine("An error occurred and your file was not uploaded.");
            Console.WriteLine(ex.StatusCode);
            Console.WriteLine(ex.Response);

            switch (ex.StatusCode)
            {
            case HttpStatusCode.Unauthorized:
                return(ExitCode.AccessDenied);

            case HttpStatusCode.Conflict:
                // Shouldn't happen with the DropNet defaults (overwrite = true), but just in case
                return(ExitCode.FileExists);
            }

            return(ExitCode.UnknownError);
        }
示例#16
0
        void Fail(DropboxException ed)
        {
            Utilities.ShowProgressIndicator(false);
            switch ((int)ed.StatusCode)
            {
            case (int)HttpStatusCode.NotFound:
                MessageBox.Show(Labels.ConnectionErrorMessage, Labels.ConnectionErrorTitle, MessageBoxButton.OK);
                return;

            case (int)HttpStatusCode.Forbidden:
                MessageBox.Show(Labels.FolderExist, Labels.ErrorTitle, MessageBoxButton.OK);
                return;

            case 507:
                MessageBox.Show(Labels.NoSpaceAvailable, Labels.ErrorTitle, MessageBoxButton.OK);
                return;
            }

            MessageBox.Show(ed.StatusCode.ToString());
        }
示例#17
0
        void DeleteFailed(DropboxException ex)
        {
            Utilities.ShowProgressIndicator(false);
            switch (ex.StatusCode)
            {
            case HttpStatusCode.Forbidden:
                MessageBox.Show(Labels.DeleteFileError, Labels.ErrorTitle, MessageBoxButton.OK);
                return;

            case HttpStatusCode.NotFound:
                MessageBox.Show(Labels.FileNotFoundDelete, Labels.ErrorTitle, MessageBoxButton.OK);
                return;

            case HttpStatusCode.NotAcceptable:
                MessageBox.Show(Labels.ServerError, Labels.ErrorTitle, MessageBoxButton.OK);
                return;

            default:
                MessageBox.Show(ex.StatusCode.ToString());
                break;
            }
        }
示例#18
0
 private void OnFail(DropboxException ex)
 {
     MessageBox.Show(Labels.UserInfoError, Labels.ErrorTitle, MessageBoxButton.OK);
 }
示例#19
0
 protected void Fail(DropboxException ed)
 {
     IsLoading = false;
     Deployment.Current.Dispatcher.BeginInvoke(() => Utilities.ShowProgressIndicator(false));
     MessageBox.Show(Labels.GenericErrorMessage, Labels.ErrorTitle, MessageBoxButton.OK);
 }
示例#20
0
 private void Can_Get_Thumbnail_Async_Failure(DropboxException error)
 {
     Assert.IsTrue(false);
 }
示例#21
0
 private void Can_Upload_Large_File_Async_Failure(DropboxException error)
 {
     Assert.IsTrue(false);
 }
示例#22
0
 void OnFail(DropboxException obj)
 {
     Debug.WriteLine(obj.Message);
 }
 // We could call GetMetadataASync() to check for file-not-found, but that'd be an extra network call.
 private static bool IsFileNotFoundException(DropboxException e)
 {
     return(e.Message == "path/not_found/");
 }
 /// <summary>
 /// DropboxException hides the true error in other properties
 /// </summary>
 private Exception CreateUsableExceptionFrom(DropboxException ex)
 {
     return(new Exception("Dropbox error " + ex.Response.ReasonPhrase + " (" + ex.StatusCode + ")", ex));
 }