public void PathNotFoundExceptionCtor1() { PathNotFoundException ex = new PathNotFoundException("message", "path"); ex.Message.Should().Be("message"); ex.Path.Should().Be("path"); }
public void PathNotFoundExceptionCtor2() { PathNotFoundException ex = new PathNotFoundException("path"); ex.Message.Should().Be("The system cannot find the path specified"); ex.Path.Should().Be("path"); }
/// <summary> /// Map a .Net IOException to the matching JSimple platform independent exception. If there's a specific exception /// type for the subclass (because it's an error we're likely to care about), return that. Otherwise, just return a /// JSimple IOException. /// </summary> public static IOException jSimpleExceptionFromDotNetIOException(System.IO.IOException e) { IOException jSimpleIOException; string message = e.Message ?? ""; // TODO: Map the other exceptions /* * if (e is java.net.SocketTimeoutException) * jSimpleIOException = new SocketTimeoutException(message); * else if (e is UnknownHostException) * jSimpleIOException = new UnknownHostException(message); */ // TODO: Include DirectoryNotFoundException for .Net apps if (e is System.IO.FileNotFoundException) { jSimpleIOException = new PathNotFoundException(message, e); } else { jSimpleIOException = new IOException(message, e); } /* * // Replace the stack trace with the original one, so it looks like the original code threw the exception. * // In some ways that's not technically correct, but it generally makes the stack traces easier to read * // and more standard Java-like, since the nested exception wrapping doesn't add any real info in error output * // and in practice tends to make error output a bit harder to understand, not easier * StackTraceElement[] stackTrace = e.getStackTrace(); * jSimpleIOException.setStackTrace(stackTrace); */ return(jSimpleIOException); }
/// <summary> /// Map a .Net IOException to the matching JSimple platform independent exception. If there's a specific exception /// type for the subclass (because it's an error we're likely to care about), return that. Otherwise, just return a /// JSimple IOException. /// </summary> public static IOException jSimpleExceptionFromDotNetIOException(System.IO.IOException e) { IOException jSimpleIOException; string message = e.Message ?? ""; // TODO: Map the other exceptions /* if (e is java.net.SocketTimeoutException) jSimpleIOException = new SocketTimeoutException(message); else if (e is UnknownHostException) jSimpleIOException = new UnknownHostException(message); */ // TODO: Include DirectoryNotFoundException for .Net apps if (e is System.IO.FileNotFoundException) jSimpleIOException = new PathNotFoundException(message, e); else jSimpleIOException = new IOException(message, e); /* // Replace the stack trace with the original one, so it looks like the original code threw the exception. // In some ways that's not technically correct, but it generally makes the stack traces easier to read // and more standard Java-like, since the nested exception wrapping doesn't add any real info in error output // and in practice tends to make error output a bit harder to understand, not easier StackTraceElement[] stackTrace = e.getStackTrace(); jSimpleIOException.setStackTrace(stackTrace); */ return jSimpleIOException; }
public void WhenMessageAndInnerExSpecified_ThenSetMessageAndInnerEx() { var innerException = new Exception(); var sut = new PathNotFoundException("Some message.", innerException); Assert.That(sut.Message, Is.EqualTo("Some message.")); Assert.That(sut.InnerException, Is.SameAs(innerException)); }
private static void Handle(PathNotFoundException ex, IExceptionHandlingContext exceptionHandlingContext) { var sb = new StringBuilder(); sb.AppendLine(SR.ErrorPathUnavailable); if (!string.IsNullOrEmpty(ex.Path)) { sb.AppendLine(string.Format(SR.FormatPath, ex.Path)); } exceptionHandlingContext.ShowMessageBox(sb.ToString()); }
public void WhenNoArgs_ThenSetMessageToDefault() { var sut = new PathNotFoundException(); Assert.That(sut.Message, Is.EqualTo("Unable to find the specified file or directory.")); }
public void WhenMessageSpecified_ThenSetMessage() { var sut = new PathNotFoundException("Some message."); Assert.That(sut.Message, Is.EqualTo("Some message.")); }
/// <summary>Create an IOE when an operation fails</summary> /// <param name="path">path of operation</param> /// <param name="operation">operation attempted</param> /// <param name="exception">caught the exception caught</param> /// <returns>an IOE to throw that contains the path and operation details.</returns> protected internal virtual IOException OperationFailure(string path, string operation , Exception exception, IList <ACL> acls) { IOException ioe; string aclList = "[" + RegistrySecurity.AclsToString(acls) + "]"; if (exception is KeeperException.NoNodeException) { ioe = new PathNotFoundException(path); } else { if (exception is KeeperException.NodeExistsException) { ioe = new FileAlreadyExistsException(path); } else { if (exception is KeeperException.NoAuthException) { ioe = new NoPathPermissionsException(path, "Not authorized to access path; ACLs: " + aclList); } else { if (exception is KeeperException.NotEmptyException) { ioe = new PathIsNotEmptyDirectoryException(path); } else { if (exception is KeeperException.AuthFailedException) { ioe = new AuthenticationFailedException(path, "Authentication Failed: " + exception + "; " + securityConnectionDiagnostics, exception); } else { if (exception is KeeperException.NoChildrenForEphemeralsException) { ioe = new NoChildrenForEphemeralsException(path, "Cannot create a path under an ephemeral node: " + exception, exception); } else { if (exception is KeeperException.InvalidACLException) { // this is a security exception of a kind // include the ACLs to help the diagnostics StringBuilder builder = new StringBuilder(); builder.Append("Path access failure ").Append(aclList); builder.Append(" "); builder.Append(securityConnectionDiagnostics); ioe = new NoPathPermissionsException(path, builder.ToString()); } else { ioe = new RegistryIOException(path, "Failure of " + operation + " on " + path + ": " + exception.ToString(), exception); } } } } } } } if (ioe.InnerException == null) { Sharpen.Extensions.InitCause(ioe, exception); } return(ioe); }