Search in sources :

Example 1 with SSLExceptionMappingService

use of ch.cyberduck.core.ssl.SSLExceptionMappingService in project cyberduck by iterate-ch.

the class DefaultIOExceptionMappingService method map.

@Override
public BackgroundException map(final IOException failure) {
    final Throwable[] stack = ExceptionUtils.getThrowables(failure);
    for (Throwable t : stack) {
        if (t instanceof BackgroundException) {
            return (BackgroundException) t;
        }
    }
    if (failure instanceof SSLException) {
        return new SSLExceptionMappingService().map((SSLException) failure);
    }
    final StringBuilder buffer = new StringBuilder();
    this.append(buffer, failure.getMessage());
    for (Throwable cause : ExceptionUtils.getThrowableList(failure)) {
        if (!StringUtils.contains(failure.getMessage(), cause.getMessage())) {
            this.append(buffer, cause.getMessage());
        }
    }
    return this.wrap(failure, buffer);
}
Also used : SSLExceptionMappingService(ch.cyberduck.core.ssl.SSLExceptionMappingService) SSLException(javax.net.ssl.SSLException) BackgroundException(ch.cyberduck.core.exception.BackgroundException)

Example 2 with SSLExceptionMappingService

use of ch.cyberduck.core.ssl.SSLExceptionMappingService in project cyberduck by iterate-ch.

the class AzureExceptionMappingService method map.

@Override
public BackgroundException map(final StorageException failure) {
    final StringBuilder buffer = new StringBuilder();
    this.append(buffer, failure.getMessage());
    if (ExceptionUtils.getRootCause(failure) instanceof UnknownHostException) {
        return new NotfoundException(buffer.toString(), failure);
    }
    switch(failure.getHttpStatusCode()) {
        case 403:
            return new LoginFailureException(buffer.toString(), failure);
        case 404:
            return new NotfoundException(buffer.toString(), failure);
        case 304:
        case 405:
        case 400:
        case 411:
        case 412:
            return new InteroperabilityException(buffer.toString(), failure);
        case 500:
            // OperationTimedOut
            return new ConnectionTimeoutException(buffer.toString(), failure);
        case 503:
            // ServerBusy
            return new RetriableAccessDeniedException(buffer.toString(), failure);
    }
    for (Throwable cause : ExceptionUtils.getThrowableList(failure)) {
        if (cause instanceof SSLException) {
            return new SSLExceptionMappingService().map(buffer.toString(), (SSLException) cause);
        }
    }
    return this.wrap(failure, buffer);
}
Also used : RetriableAccessDeniedException(ch.cyberduck.core.exception.RetriableAccessDeniedException) NotfoundException(ch.cyberduck.core.exception.NotfoundException) ConnectionTimeoutException(ch.cyberduck.core.exception.ConnectionTimeoutException) LoginFailureException(ch.cyberduck.core.exception.LoginFailureException) InteroperabilityException(ch.cyberduck.core.exception.InteroperabilityException) SSLExceptionMappingService(ch.cyberduck.core.ssl.SSLExceptionMappingService) UnknownHostException(java.net.UnknownHostException) SSLException(javax.net.ssl.SSLException)

Aggregations

SSLExceptionMappingService (ch.cyberduck.core.ssl.SSLExceptionMappingService)2 SSLException (javax.net.ssl.SSLException)2 BackgroundException (ch.cyberduck.core.exception.BackgroundException)1 ConnectionTimeoutException (ch.cyberduck.core.exception.ConnectionTimeoutException)1 InteroperabilityException (ch.cyberduck.core.exception.InteroperabilityException)1 LoginFailureException (ch.cyberduck.core.exception.LoginFailureException)1 NotfoundException (ch.cyberduck.core.exception.NotfoundException)1 RetriableAccessDeniedException (ch.cyberduck.core.exception.RetriableAccessDeniedException)1 UnknownHostException (java.net.UnknownHostException)1