// 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); }
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 }
//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); }
//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); }
/// <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); }
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"); }