Example usage for java.nio.file FileSystemException FileSystemException

List of usage examples for java.nio.file FileSystemException FileSystemException

Introduction

In this page you can find the example usage for java.nio.file FileSystemException FileSystemException.

Prototype

public FileSystemException(String file, String other, String reason) 

Source Link

Document

Constructs an instance of this class.

Usage

From source file:org.modelio.vbasic.net.ApacheUriConnection.java

/**
 * Builds and throws a {@link FileSystemException} from {@link #res}.
 * <p>/*from   w ww.j  a v  a2  s.c  o m*/
 * Adds as cause another exception whose message is the entity content. This may be the HTML message sent by the server.
 * @throws java.nio.file.FileSystemException the built exception
 */
@objid("4e25ec1d-3711-45cc-b742-0c77edf5e414")
private void handleConnectionFailure() throws FileSystemException {
    StatusLine statusLine = this.res.getStatusLine();
    String reason = statusLine.getReasonPhrase();

    Exception base = null;
    try {
        String s = EntityUtils.toString(this.res.getEntity());
        if (s != null)
            base = new HttpResponseException(statusLine.getStatusCode(), s);
    } catch (IOException e) {
        base = e;
    }

    FileSystemException error;

    int statusCode = statusLine.getStatusCode();
    if (statusCode == HttpStatus.SC_FORBIDDEN) {
        error = new AccessDeniedException(this.uri.toString(), null, reason);
    } else if (statusCode == HttpStatus.SC_UNAUTHORIZED
            || statusCode == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
        error = new UriAuthenticationException(this.uri.toString(), reason);
    } else if (statusCode == HttpStatus.SC_NOT_FOUND) {
        error = new NoSuchFileException(this.uri.toString(), null, reason);
    } else {
        error = new FileSystemException(this.uri.toString(), null, reason);
    }

    if (base != null)
        error.initCause(base);

    throw error;
}