Exemplo n.º 1
0
        // returns true if the caller can continue; otherwise is false.
        internal bool HandleException(Exception exc, bool showError)
        {
            if (exc.InnerException != null)
            {
                exc = exc.InnerException;
            }

            FileSystemException foe = exc as FileSystemException;

            if (foe != null && foe.Status == FileSystemExceptionStatus.OperationCancelled)
            {
                return(true);
            }

            if (_clientPlugin.CanBeReconnected(exc))
            {
                Reconnect();
                return(false);
            }

            if (showError)
            {
                _view.ShowError(exc);
            }
            return(true);
        }
Exemplo n.º 2
0
        public static void ShowError(Exception exc)
        {
            FileSystemException fexc = exc as FileSystemException;

            if (fexc != null && fexc.Status == FileSystemExceptionStatus.OperationCancelled)
            {
                return;
            }

#if DEBUG && false
            throw exc;
#else
            string str;

            if (exc.InnerException != null)
            {
                str = string.Format(null, "An error occurred: {0}", exc.InnerException.Message);
            }
            else
            {
                str = string.Format(null, "An error occurred: {0}", exc.Message);
            }


            MessageBox.Show(str, "Error");
#endif
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldGiveAClearErrorMessageIfTheDestinationsParentDirectoryIsAFile() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldGiveAClearErrorMessageIfTheDestinationsParentDirectoryIsAFile()
        {
            Path archive     = _testDirectory.file("the-archive.dump").toPath();
            Path destination = Paths.get(_testDirectory.absolutePath().AbsolutePath, "subdir", "the-destination");

            Files.write(destination.Parent, new sbyte[0]);
            FileSystemException exception = assertThrows(typeof(FileSystemException), () => (new Loader()).load(archive, destination, destination));

            assertEquals(destination.Parent.ToString() + ": Not a directory", exception.Message);
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldGiveAClearErrorMessageIfTheArchivesParentDirectoryIsAFile() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldGiveAClearErrorMessageIfTheArchivesParentDirectoryIsAFile()
        {
            Path directory = _testDirectory.directory("a-directory").toPath();
            Path archive   = _testDirectory.file("subdir/the-archive.dump").toPath();

            Files.write(archive.Parent, new sbyte[0]);
            FileSystemException exception = assertThrows(typeof(FileSystemException), () => (new Dumper()).dump(directory, directory, archive, GZIP, Predicates.alwaysFalse()));

            assertEquals(archive.Parent.ToString() + ": Not a directory", exception.Message);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Checks if the specified error is user cancelled exception.
        /// </summary>
        public static bool IsFileSystemOperationCancelled(Exception ex)
        {
            FileSystemException fe = ex as FileSystemException;

            if (fe != null && fe.Status == FileSystemExceptionStatus.OperationCancelled)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        public static void ShowError(Exception exc)
        {
            while (exc.InnerException != null)
            {
                exc = exc.InnerException;
            }

            FileSystemException fexc = exc as FileSystemException;

            if (fexc != null && fexc.Status == FileSystemExceptionStatus.OperationCancelled)
            {
                return;
            }

            string str = string.Format(null, "An error occurred: {0}", exc.Message);

            MessageBox.Show(str, "Error");
        }