1 package ch
.cyberduck
.core
;
4 * Copyright (c) 2013 David Kocher. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to:
18 * dkocher@cyberduck.ch
21 import ch
.cyberduck
.core
.exception
.BackgroundException
;
23 import org
.apache
.commons
.lang3
.StringUtils
;
24 import org
.apache
.commons
.lang3
.exception
.ExceptionUtils
;
26 import java
.io
.IOException
;
31 public class DefaultIOExceptionMappingService
extends AbstractExceptionMappingService
<IOException
> {
33 public BackgroundException
map(final IOException failure
, final Path directory
) {
34 return super.map("Connection failed", failure
, directory
);
38 public BackgroundException
map(final IOException failure
) {
39 if(ExceptionUtils
.getCause(failure
) instanceof BackgroundException
) {
40 return (BackgroundException
) ExceptionUtils
.getCause(failure
);
42 final StringBuilder buffer
= new StringBuilder();
43 this.append(buffer
, failure
.getMessage());
44 for(Throwable cause
: ExceptionUtils
.getThrowableList(failure
)) {
45 if(!StringUtils
.contains(failure
.getMessage(), cause
.getMessage())) {
46 this.append(buffer
, cause
.getMessage());
49 return this.wrap(failure
, buffer
);