Source:
public void handleError(HttpCommand command, HttpResponse response) { byte[] data = closeClientButKeepContentStream(response); String message = data != null ? new String(data) : null; Exception exception = message != null ? new HttpResponseException(command, response, message) : new HttpResponseException(command, response); message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); switch (response.getStatusCode()) { case 401: exception = new AuthorizationException(exception.getMessage(), exception); break; case 404: String sourcePath = command.getCurrentRequest().getFirstHeaderOrNull(SwiftHeaders.OBJECT_COPY_FROM); Exception oldException = exception; if (sourcePath != null) { String path = command.getCurrentRequest().getEndpoint().getPath(); int startOfDestinationPath = path.lastIndexOf("/", path.lastIndexOf("/") - 1); String destinationPath = path.substring(startOfDestinationPath); exception = new CopyObjectException(sourcePath, destinationPath, message); exception.initCause(oldException); } else if (!command.getCurrentRequest().getMethod().equals("DELETE")) { String path = command.getCurrentRequest().getEndpoint().getPath(); Matcher matcher = CONTAINER_PATH.matcher(path); if (matcher.find()) { exception = new ContainerNotFoundException(matcher.group(1), message); exception.initCause(oldException); } else { matcher = CONTAINER_KEY_PATH.matcher(path); if (matcher.find()) { exception = new KeyNotFoundException(matcher.group(1), matcher.group(2), message); exception.initCause(oldException); } } } break; case 409: exception = new IllegalStateException(exception.getMessage(), exception); break; } command.setException(exception); }

Target:
public void handleError(HttpCommand command, HttpResponse response) { byte[] data = closeClientButKeepContentStream(response); String message = data != null ? new String(data) : null; Exception exception = message != null ? new HttpResponseException(command, response, message) : new HttpResponseException(command, response); message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); switch (response.getStatusCode()) { case 401: exception = new AuthorizationException(exception.getMessage(), exception); break; case 404: Exception oldException = exception; String sourcePath = command.getCurrentRequest().getFirstHeaderOrNull(SwiftHeaders.OBJECT_COPY_FROM); if (sourcePath != null) { String path = command.getCurrentRequest().getEndpoint().getPath(); int startOfDestinationPath = path.lastIndexOf("/", path.lastIndexOf("/") - 1); String destinationPath = path.substring(startOfDestinationPath); exception = new CopyObjectException(sourcePath, destinationPath, message); exception.initCause(oldException); } else if (!command.getCurrentRequest().getMethod().equals("DELETE")) { String path = command.getCurrentRequest().getEndpoint().getPath(); Matcher matcher = CONTAINER_PATH.matcher(path); if (matcher.find()) { exception = new ContainerNotFoundException(matcher.group(1), message); exception.initCause(oldException); } else { matcher = CONTAINER_KEY_PATH.matcher(path); if (matcher.find()) { exception = new KeyNotFoundException(matcher.group(1), matcher.group(2), message); exception.initCause(oldException); } } } break; case 409: exception = new IllegalStateException(exception.getMessage(), exception); break; } command.setException(exception); }