Example usage for java.io IOException getCause

List of usage examples for java.io IOException getCause

Introduction

In this page you can find the example usage for java.io IOException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:edu.harvard.iq.dataverse.api.imports.ImportServiceBean.java

@TransactionAttribute(REQUIRES_NEW)
public JsonObjectBuilder handleFile(DataverseRequest dataverseRequest, Dataverse owner, File file,
        ImportType importType, PrintWriter validationLog, PrintWriter cleanupLog)
        throws ImportException, IOException {

    System.out.println("handling file: " + file.getAbsolutePath());
    String ddiXMLToParse;//ww w  . j  av a  2s  .  c  o  m
    try {
        ddiXMLToParse = new String(Files.readAllBytes(file.toPath()));
        JsonObjectBuilder status = doImport(dataverseRequest, owner, ddiXMLToParse,
                file.getParentFile().getName() + "/" + file.getName(), importType, cleanupLog);
        status.add("file", file.getName());
        logger.log(Level.INFO, "completed doImport {0}/{1}",
                new Object[] { file.getParentFile().getName(), file.getName() });
        return status;
    } catch (ImportException ex) {
        String msg = "Import Exception processing file " + file.getParentFile().getName() + "/" + file.getName()
                + ", msg:" + ex.getMessage();
        logger.info(msg);
        if (validationLog != null) {
            validationLog.println(msg);
        }
        return Json.createObjectBuilder().add("message", "Import Exception processing file "
                + file.getParentFile().getName() + "/" + file.getName() + ", msg:" + ex.getMessage());
    } catch (IOException e) {
        Throwable causedBy = e.getCause();
        while (causedBy != null && causedBy.getCause() != null) {
            causedBy = causedBy.getCause();
        }
        String stackLine = "";
        if (causedBy != null && causedBy.getStackTrace() != null && causedBy.getStackTrace().length > 0) {
            stackLine = causedBy.getStackTrace()[0].toString();
        }
        String msg = "Unexpected Error in handleFile(), file:" + file.getParentFile().getName() + "/"
                + file.getName();
        if (e.getMessage() != null) {
            msg += "message: " + e.getMessage();
        }
        msg += ", caused by: " + causedBy;
        if (causedBy != null && causedBy.getMessage() != null) {
            msg += ", caused by message: " + causedBy.getMessage();
        }
        msg += " at line: " + stackLine;

        validationLog.println(msg);
        e.printStackTrace();

        return Json.createObjectBuilder().add("message", "Unexpected Exception processing file "
                + file.getParentFile().getName() + "/" + file.getName() + ", msg:" + e.getMessage());

    }
}

From source file:com.redhat.ceylon.cmr.repository.webdav.WebDAVRepository.java

public String getBetterExceptionMessage(IOException x, String root) {
    if (x instanceof SardineException) {
        // hide this from callers because its getMessage() is borked
        SardineException sx = (SardineException) x;
        if (sx.getStatusCode() == HttpURLConnection.HTTP_FORBIDDEN) {
            return "authentication failed on repository " + root;
        }//from  w w  w.  j ava  2 s .  c o  m
        return sx.getMessage() + ": " + sx.getResponsePhrase() + " " + sx.getStatusCode();
    }
    if (x instanceof ClientProtocolException) {
        // in case of protocol exception (invalid response) we get this sort of
        // chain set up with a null message, so unwrap it for better messages
        if (x.getCause() != null && x.getCause() instanceof ProtocolException)
            return x.getCause().getMessage();
    }
    return null;
}

From source file:org.opendatakit.tables.tasks.InitializeTask.java

private void extractFromRawZip(int resourceId, boolean overwrite, ArrayList<String> result) {
    String message = null;/*from ww w .  ja  v a 2 s.c om*/
    AssetFileDescriptor fd = null;
    try {
        fd = mContext.getResources().openRawResourceFd(resourceId);
        final long size = fd.getLength() / 2L; // apparently over-counts by 2x?
        InputStream rawInputStream = null;
        try {
            rawInputStream = fd.createInputStream();
            ZipInputStream zipInputStream = null;
            ZipEntry entry = null;
            try {

                // count the number of files in the zip
                zipInputStream = new ZipInputStream(rawInputStream);
                int totalFiles = 0;
                while ((entry = zipInputStream.getNextEntry()) != null) {
                    message = null;
                    if (isCancelled()) {
                        message = "cancelled";
                        result.add(entry.getName() + " " + message);
                        break;
                    }
                    ++totalFiles;
                }
                zipInputStream.close();

                // and re-open the stream, reading it this time...
                fd = mContext.getResources().openRawResourceFd(resourceId);
                rawInputStream = fd.createInputStream();
                zipInputStream = new ZipInputStream(rawInputStream);

                long bytesProcessed = 0L;
                long lastBytesProcessedThousands = 0L;
                int nFiles = 0;
                while ((entry = zipInputStream.getNextEntry()) != null) {
                    message = null;
                    if (isCancelled()) {
                        message = "cancelled";
                        result.add(entry.getName() + " " + message);
                        break;
                    }
                    ++nFiles;
                    File tempFile = new File(ODKFileUtils.getAppFolder(mAppName), entry.getName());
                    String formattedString = mContext.getString(R.string.expansion_unzipping_without_detail,
                            entry.getName(), nFiles, totalFiles);
                    String detail;
                    if (entry.isDirectory()) {
                        detail = mContext.getString(R.string.expansion_create_dir_detail);
                        publishProgress(formattedString, detail);
                        tempFile.mkdirs();
                    } else {
                        int bufferSize = 8192;
                        OutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile, false),
                                bufferSize);
                        byte buffer[] = new byte[bufferSize];
                        int bread;
                        while ((bread = zipInputStream.read(buffer)) != -1) {
                            bytesProcessed += bread;
                            long curThousands = (bytesProcessed / 1000L);
                            if (curThousands != lastBytesProcessedThousands) {
                                detail = mContext.getString(R.string.expansion_unzipping_detail, bytesProcessed,
                                        size);
                                publishProgress(formattedString, detail);
                                lastBytesProcessedThousands = curThousands;
                            }
                            out.write(buffer, 0, bread);
                        }
                        out.flush();
                        out.close();

                        detail = mContext.getString(R.string.expansion_unzipping_detail, bytesProcessed, size);
                        publishProgress(formattedString, detail);
                    }
                    WebLogger.getLogger(mAppName).i(TAG, "Extracted ZipEntry: " + entry.getName());

                    message = mContext.getString(R.string.success);
                    result.add(entry.getName() + " " + message);
                }

                ODKFileUtils.assertConfiguredTablesApp(mAppName, Tables.getInstance().getVersionCodeString());

                String completionString = mContext.getString(R.string.expansion_unzipping_complete, totalFiles);
                publishProgress(completionString, null);
            } catch (IOException e) {
                WebLogger.getLogger(mAppName).printStackTrace(e);
                mPendingSuccess = false;
                if (e.getCause() != null) {
                    message = e.getCause().getMessage();
                } else {
                    message = e.getMessage();
                }
                if (entry != null) {
                    result.add(entry.getName() + " " + message);
                } else {
                    result.add("Error accessing zipfile resource " + message);
                }
            } finally {
                if (zipInputStream != null) {
                    try {
                        zipInputStream.close();
                        rawInputStream = null;
                        fd = null;
                    } catch (IOException e) {
                        WebLogger.getLogger(mAppName).printStackTrace(e);
                        WebLogger.getLogger(mAppName).e(TAG, "Closing of ZipFile failed: " + e.toString());
                    }
                }
                if (rawInputStream != null) {
                    try {
                        rawInputStream.close();
                        fd = null;
                    } catch (IOException e) {
                        WebLogger.getLogger(mAppName).printStackTrace(e);
                        WebLogger.getLogger(mAppName).e(TAG, "Closing of ZipFile failed: " + e.toString());
                    }
                }
                if (fd != null) {
                    try {
                        fd.close();
                    } catch (IOException e) {
                        WebLogger.getLogger(mAppName).printStackTrace(e);
                        WebLogger.getLogger(mAppName).e(TAG, "Closing of ZipFile failed: " + e.toString());
                    }
                }
            }
        } catch (Exception e) {
            WebLogger.getLogger(mAppName).printStackTrace(e);
            mPendingSuccess = false;
            if (e.getCause() != null) {
                message = e.getCause().getMessage();
            } else {
                message = e.getMessage();
            }
            result.add("Error accessing zipfile resource " + message);
        } finally {
            if (rawInputStream != null) {
                try {
                    rawInputStream.close();
                } catch (IOException e) {
                    WebLogger.getLogger(mAppName).printStackTrace(e);
                }
            }
        }
    } finally {
        if (fd != null) {
            try {
                fd.close();
            } catch (IOException e) {
                WebLogger.getLogger(mAppName).printStackTrace(e);
            }
        } else {
            result.add("Error accessing zipfile resource.");
        }
    }
}

From source file:com.nts.alphamale.shell.AdbShellExecutor.java

/**
 * @param cmd adb /*from w  w  w  .ja v a  2  s. co m*/
 * @param synch   ? ? true: synchronous, false: asynchronous
 * @param  (ms)
 * @return Executor Standard Output? Map
 */
public Map<String, Object> execute(CommandLine cmd, boolean synch, long timeoutMilliseconds) {
    Map<String, Object> executorMap = new HashMap<String, Object>();
    DefaultExecutor executor = new DefaultExecutor();
    PipedOutputStream pos = new PipedOutputStream();
    PumpStreamHandler streamHandler = new PumpStreamHandler(pos, System.err);
    streamHandler.setStopTimeout(timeoutMilliseconds);
    DataInputStream dis = null;
    try {
        dis = new DataInputStream(new PipedInputStream(pos));
    } catch (IOException e) {
        //log.error(e.getCause() + " : " + e.getMessage());
    }
    executor.setStreamHandler(streamHandler);
    ExecuteWatchdog watchDog = new ExecuteWatchdog(timeoutMilliseconds);
    executor.setWatchdog(watchDog);
    try {
        if (synch)
            executor.execute(cmd);
        else
            executor.execute(cmd, new DefaultExecuteResultHandler());

        log.debug(cmd.toString());
        LineIterator li = IOUtils.lineIterator(dis, "UTF-8");
        if (li != null) {
            executorMap.put("executor", executor);
            executorMap.put("stdOut", li);
        }
    } catch (Exception e) {
        log.error(e.getCause() + ":" + e.getMessage() + "[" + cmd + "]");
    }
    return executorMap;
}

From source file:org.apache.tika.parser.pdf.AbstractPDF2XHTML.java

void handleCatchableIOE(IOException e) throws IOException {
    if (config.isCatchIntermediateIOExceptions()) {
        if (e.getCause() instanceof SAXException && e.getCause().getMessage() != null
                && e.getCause().getMessage().contains("Your document contained more than")) {
            //TODO -- is there a cleaner way of checking for:
            // WriteOutContentHandler.WriteLimitReachedException?
            throw e;
        }/* w  w w .  j a  v  a 2s.  com*/

        String msg = e.getMessage();
        if (msg == null) {
            msg = "IOException, no message";
        }
        metadata.add(TikaCoreProperties.TIKA_META_EXCEPTION_WARNING, msg);
        exceptions.add(e);
    } else {
        throw e;
    }
}

From source file:org.codelibs.fess.helper.ViewHelper.java

protected StreamResponse writeContent(final String configId, final String url, final CrawlerClient client) {
    final StreamResponse response = new StreamResponse(StringUtil.EMPTY);
    final ResponseData responseData = client
            .execute(RequestDataBuilder.newRequestData().get().url(url).build());
    if (responseData.getHttpStatusCode() == 404) {
        response.httpStatus(responseData.getHttpStatusCode());
        CloseableUtil.closeQuietly(responseData);
        return response;
    }/*from   www  . j  a  va  2  s  .  com*/
    writeFileName(response, responseData);
    writeContentType(response, responseData);
    writeNoCache(response, responseData);
    response.stream(out -> {
        try (final InputStream is = new BufferedInputStream(responseData.getResponseBody())) {
            out.write(is);
        } catch (final IOException e) {
            if (!(e.getCause() instanceof ClientAbortException)) {
                throw new FessSystemException(
                        "Failed to write a content. configId: " + configId + ", url: " + url, e);
            }
        } finally {
            CloseableUtil.closeQuietly(responseData);
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Finished to write " + url);
        }
    });
    return response;
}

From source file:org.lockss.plugin.base.TestDefaultUrlCacher.java

public void testCopyInputError() throws Exception {
    InputStream input = new ThrowingInputStream(new StringInputStream("will throw"),
            new IOException("Malformed chunk"), null);
    ud = new UrlData(input, new CIProperties(), TEST_URL);
    cacher = new MyDefaultUrlCacher(mau, ud);
    try {//from w  w w . ja  va 2s .  c  o m
        cacher.storeContent();
        fail("Copy should have thrown");
    } catch (IOException e) {
        Throwable t = e.getCause();
        assertClass(IOException.class, t);
        assertEquals("java.io.IOException: Malformed chunk", t.getMessage());
    }
}

From source file:org.lockss.plugin.base.TestDefaultUrlCacher.java

public void testCopyInputErrorOnClose() throws Exception {
    InputStream input = new ThrowingInputStream(new StringInputStream("will throw"), null,
            new IOException("CRLF expected at end of chunk: -1/-1"));
    ud = new UrlData(input, new CIProperties(), TEST_URL);
    cacher = new MyDefaultUrlCacher(mau, ud);
    try {/*from w w w  . j  ava  2s .  com*/
        cacher.storeContent();
        fail("Copy should have thrown");
    } catch (IOException e) {
        Throwable t = e.getCause();
        assertClass(IOException.class, t);
        assertEquals("java.io.IOException: CRLF expected at end of chunk: -1/-1", t.getMessage());
    }
}

From source file:com.mirth.connect.connectors.tcp.TcpDispatcher.java

@Override
public Response send(ConnectorProperties connectorProperties, ConnectorMessage message) {
    TcpDispatcherProperties tcpDispatcherProperties = (TcpDispatcherProperties) connectorProperties;
    Status responseStatus = Status.QUEUED;
    String responseData = null;/*from  w ww .j ava2 s . co  m*/
    String responseStatusMessage = null;
    String responseError = null;
    boolean validateResponse = false;

    long dispatcherId = getDispatcherId();

    String socketKey = dispatcherId + tcpDispatcherProperties.getRemoteAddress()
            + tcpDispatcherProperties.getRemotePort();
    if (tcpDispatcherProperties.isOverrideLocalBinding()) {
        socketKey += tcpDispatcherProperties.getLocalAddress() + tcpDispatcherProperties.getLocalPort();
    }

    Socket socket = null;
    Thread timeoutThread = null;

    try {
        // Do some validation first to avoid unnecessarily creating sockets
        if (StringUtils.isBlank(tcpDispatcherProperties.getRemoteAddress())) {
            throw new Exception("Remote address is blank.");
        } else if (NumberUtils.toInt(tcpDispatcherProperties.getRemotePort()) <= 0) {
            throw new Exception("Remote port is invalid.");
        }

        socket = connectedSockets.get(socketKey);
        timeoutThread = timeoutThreads.get(socketKey);

        // If keep connection open is true, then interrupt the thread so it won't close the socket
        if (tcpDispatcherProperties.isKeepConnectionOpen() && timeoutThread != null) {
            disposeThreadQuietly(socketKey);
        }

        // Initialize a new socket if our current one is invalid, the remote side has closed, or keep connection open is false
        if (!tcpDispatcherProperties.isKeepConnectionOpen() || socket == null || socket.isClosed()
                || (tcpDispatcherProperties.isCheckRemoteHost() && socket instanceof StateAwareSocketInterface
                        && ((StateAwareSocketInterface) socket).remoteSideHasClosed())) {
            closeSocketQuietly(socketKey);

            logger.debug("Creating new socket (" + connectorProperties.getName() + " \"" + getDestinationName()
                    + "\" on channel " + getChannelId() + ").");
            String info = "Trying to connect on " + tcpDispatcherProperties.getRemoteAddress() + ":"
                    + tcpDispatcherProperties.getRemotePort() + "...";
            eventController.dispatchEvent(new ConnectionStatusEvent(getChannelId(), getMetaDataId(),
                    getDestinationName(), ConnectionStatusEventType.CONNECTING, info));

            if (tcpDispatcherProperties.isOverrideLocalBinding()) {
                socket = SocketUtil.createSocket(configuration, tcpDispatcherProperties.getLocalAddress(),
                        NumberUtils.toInt(tcpDispatcherProperties.getLocalPort()));
            } else {
                socket = SocketUtil.createSocket(configuration);
            }

            ThreadUtils.checkInterruptedStatus();
            connectedSockets.put(socketKey, socket);

            SocketUtil.connectSocket(socket, tcpDispatcherProperties.getRemoteAddress(),
                    NumberUtils.toInt(tcpDispatcherProperties.getRemotePort()), responseTimeout);

            socket.setReuseAddress(true);
            socket.setReceiveBufferSize(bufferSize);
            socket.setSendBufferSize(bufferSize);
            socket.setSoTimeout(responseTimeout);
            socket.setKeepAlive(tcpDispatcherProperties.isKeepConnectionOpen());

            eventController.dispatchEvent(new ConnectorCountEvent(getChannelId(), getMetaDataId(),
                    getDestinationName(), ConnectionStatusEventType.CONNECTED,
                    SocketUtil.getLocalAddress(socket) + " -> " + SocketUtil.getInetAddress(socket), true));
        }

        ThreadUtils.checkInterruptedStatus();

        // Send the message
        eventController.dispatchEvent(new ConnectionStatusEvent(getChannelId(), getMetaDataId(),
                getDestinationName(), ConnectionStatusEventType.SENDING,
                SocketUtil.getLocalAddress(socket) + " -> " + SocketUtil.getInetAddress(socket)));
        BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream(), bufferSize);
        BatchStreamReader batchStreamReader = new DefaultBatchStreamReader(socket.getInputStream());
        StreamHandler streamHandler = transmissionModeProvider.getStreamHandler(socket.getInputStream(), bos,
                batchStreamReader, tcpDispatcherProperties.getTransmissionModeProperties());
        streamHandler.write(getTemplateBytes(tcpDispatcherProperties, message));
        bos.flush();

        if (!tcpDispatcherProperties.isIgnoreResponse()) {
            ThreadUtils.checkInterruptedStatus();

            // Attempt to get the response from the remote endpoint
            try {
                String info = "Waiting for response from " + SocketUtil.getInetAddress(socket) + " (Timeout: "
                        + tcpDispatcherProperties.getResponseTimeout() + " ms)... ";
                eventController.dispatchEvent(new ConnectionStatusEvent(getChannelId(), getMetaDataId(),
                        getDestinationName(), ConnectionStatusEventType.WAITING_FOR_RESPONSE, info));
                byte[] responseBytes = streamHandler.read();
                if (responseBytes != null) {
                    responseData = new String(responseBytes,
                            CharsetUtils.getEncoding(tcpDispatcherProperties.getCharsetEncoding()));
                    responseStatusMessage = "Message successfully sent.";
                } else {
                    responseStatusMessage = "Message successfully sent, but no response received.";
                }

                streamHandler.commit(true);
                responseStatus = Status.SENT;

                // We only want to validate the response if we were able to retrieve it successfully
                validateResponse = tcpDispatcherProperties.getDestinationConnectorProperties()
                        .isValidateResponse();
            } catch (IOException e) {
                // An exception occurred while retrieving the response
                if (e instanceof SocketTimeoutException
                        || e.getCause() != null && e.getCause() instanceof SocketTimeoutException) {
                    responseStatusMessage = "Timeout waiting for response";

                    if (!tcpDispatcherProperties.isQueueOnResponseTimeout()) {
                        responseStatus = Status.ERROR;
                    }
                } else {
                    responseStatusMessage = "Error receiving response";
                }

                responseError = ErrorMessageBuilder.buildErrorMessage(connectorProperties.getName(),
                        responseStatusMessage + ": " + e.getMessage(), e);
                logger.warn(responseStatusMessage + " (" + connectorProperties.getName() + " \""
                        + getDestinationName() + "\" on channel " + getChannelId() + ").", e);
                eventController.dispatchEvent(new ErrorEvent(getChannelId(), getMetaDataId(),
                        message.getMessageId(), ErrorEventType.DESTINATION_CONNECTOR, getDestinationName(),
                        connectorProperties.getName(), responseStatusMessage + ".", e));
                eventController.dispatchEvent(new ConnectionStatusEvent(getChannelId(), getMetaDataId(),
                        getDestinationName(), ConnectionStatusEventType.FAILURE,
                        responseStatusMessage + " from " + SocketUtil.getInetAddress(socket)));

                closeSocketQuietly(socketKey);
            }
        } else {
            try {
                // MIRTH-2980: Since we're ignoring responses, flush out the socket's input stream so it doesn't continually grow
                socket.getInputStream().skip(socket.getInputStream().available());
            } catch (IOException e) {
                logger.warn("Error flushing socket input stream.", e);
            }

            // We're ignoring the response, so always return a successful response
            responseStatus = Status.SENT;
            responseStatusMessage = "Message successfully sent.";
        }

        if (tcpDispatcherProperties.isKeepConnectionOpen() && (getCurrentState() == DeployedState.STARTED
                || getCurrentState() == DeployedState.STARTING)) {
            if (sendTimeout > 0) {
                // Close the connection after the send timeout has been reached
                startThread(socketKey);
            }
        } else {
            // If keep connection open is false, then close the socket right now
            closeSocketQuietly(socketKey);
        }
    } catch (Throwable t) {
        disposeThreadQuietly(socketKey);
        closeSocketQuietly(socketKey);

        String monitorMessage = "Error sending message (" + SocketUtil.getLocalAddress(socket) + " -> "
                + SocketUtil.getInetAddress(socket) + "): " + t.getMessage();
        eventController.dispatchEvent(new ConnectionStatusEvent(getChannelId(), getMetaDataId(),
                getDestinationName(), ConnectionStatusEventType.FAILURE, monitorMessage));

        // If an exception occurred then close the socket, even if keep connection open is true
        responseStatusMessage = t.getClass().getSimpleName() + ": " + t.getMessage();
        responseError = ErrorMessageBuilder.buildErrorMessage(connectorProperties.getName(), t.getMessage(), t);

        String logMessage = "Error sending message via TCP (" + connectorProperties.getName() + " \""
                + getDestinationName() + "\" on channel " + getChannelId() + ").";

        if (t instanceof InterruptedException) {
            Thread.currentThread().interrupt();
        } else if (t instanceof ConnectException
                || t.getCause() != null && t.getCause() instanceof ConnectException) {
            if (isQueueEnabled()) {
                logger.warn(logMessage, t);
            } else {
                logger.error(logMessage, t);
            }
        } else {
            logger.debug(logMessage, t);
        }

        eventController.dispatchEvent(new ErrorEvent(getChannelId(), getMetaDataId(), message.getMessageId(),
                ErrorEventType.DESTINATION_CONNECTOR, getDestinationName(), connectorProperties.getName(),
                "Error sending message via TCP.", t));
    } finally {
        eventController.dispatchEvent(new ConnectorCountEvent(getChannelId(), getMetaDataId(),
                getDestinationName(), ConnectionStatusEventType.IDLE,
                SocketUtil.getLocalAddress(socket) + " -> " + SocketUtil.getInetAddress(socket),
                (Boolean) null));
    }

    return new Response(responseStatus, responseData, responseStatusMessage, responseError, validateResponse);
}

From source file:twitter4j.internal.http.alternative.AppEngineHttpResponseImpl.java

private void ensureResponseEvaluated() {
    if (th != null) {
        throw new TwitterRuntimeException(th);
    }//from   w ww. j a  v  a 2s  .com
    if (responseGot) {
        return;
    }
    responseGot = true;
    if (future.isCancelled()) {
        th = new TwitterException("HttpResponse already disconnected.");
        throw new TwitterRuntimeException(th);
    }
    try {
        HTTPResponse r = future.get();
        statusCode = r.getResponseCode();
        headers = new HashMap<String, String>();
        for (HTTPHeader h : r.getHeaders()) {
            headers.put(h.getName().toLowerCase(Locale.ENGLISH), h.getValue());
        }
        byte[] content = r.getContent();
        is = new ByteArrayInputStream(content);
        if ("gzip".equals(headers.get("content-encoding"))) {
            // the response is gzipped
            try {
                is = new GZIPInputStream(is);
            } catch (IOException e) {
                th = e;
                throw new TwitterRuntimeException(th);
            }
        }
        responseAsString = inputStreamToString(is);
        if (statusCode < OK || (statusCode != FOUND && MULTIPLE_CHOICES <= statusCode)) {
            if (statusCode == ENHANCE_YOUR_CLAIM || statusCode == BAD_REQUEST
                    || statusCode < INTERNAL_SERVER_ERROR) {
                th = new TwitterException(responseAsString, null, statusCode);
                throw new TwitterRuntimeException(th);
            }
        }
    } catch (ExecutionException e) {
        th = e.getCause();
    } catch (InterruptedException e) {
        th = e.getCause();
    }
    if (th != null) {
        throw new TwitterRuntimeException(th);
    }
}