Example usage for java.lang Throwable getMessage

List of usage examples for java.lang Throwable getMessage

Introduction

In this page you can find the example usage for java.lang Throwable getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.zalando.stups.tokens.AbstractJsonFileBackedCredentialsProvider.java

protected <T> T read(final Class<T> cls) {
    try {/*w  w  w .jav  a2s  . c om*/
        return OBJECT_MAPPER.readValue(getFile(), cls);
    } catch (final Throwable e) {
        throw new CredentialsUnavailableException(e.getMessage(), e);
    }
}

From source file:com.sforce.dataset.DatasetUtilMain.java

public static File validateInputFile(String inputFile, String action) {
    File temp = null;//from   w w  w . ja v  a2 s .  c  o  m
    if (inputFile != null) {
        temp = new File(inputFile);
        if (!temp.exists() && !temp.canRead()) {
            System.out.println("\nERROR: inputFile {" + temp + "} not found");
            return null;
        }

        String ext = FilenameUtils.getExtension(temp.getName());
        if (ext == null || !(ext.equalsIgnoreCase("csv") || ext.equalsIgnoreCase("txt")
                || ext.equalsIgnoreCase("bin") || ext.equalsIgnoreCase("gz") || ext.equalsIgnoreCase("json"))) {
            System.out.println("\nERROR: inputFile does not have valid extension");
            return null;
        }

        if (action.equalsIgnoreCase("load")) {
            byte[] binHeader = new byte[5];
            if (ext.equalsIgnoreCase("bin") || ext.equalsIgnoreCase("gz")) {
                try {
                    InputStream fis = new FileInputStream(temp);
                    if (ext.equalsIgnoreCase("gz"))
                        fis = new GzipCompressorInputStream(new FileInputStream(temp));
                    int cnt = fis.read(binHeader);
                    if (fis != null) {
                        IOUtils.closeQuietly(fis);
                    }
                    if (cnt < 5) {
                        System.out.println("\nERROR: inputFile {" + temp + "} in not valid");
                        return null;
                    }
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                    System.out.println("\nERROR: inputFile {" + temp + "} not found");
                    return null;
                } catch (IOException e) {
                    e.printStackTrace();
                    System.out.println("\nERROR: inputFile {" + temp + "} in not valid");
                    return null;
                }

                if (!EbinFormatWriter.isValidBin(binHeader)) {
                    if (ext.equalsIgnoreCase("bin")) {
                        System.out.println("\nERROR: inputFile {" + temp + "} in not valid binary file");
                        return null;
                    }
                }
            }
        }

        if (ext.equalsIgnoreCase("json")) {
            try {
                ObjectMapper mapper = new ObjectMapper();
                mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                mapper.readValue(temp, Object.class);
            } catch (Throwable t) {
                System.out.println(
                        "\nERROR: inputFile {" + temp + "} is not valid json, Error: " + t.getMessage());
                return null;
            }
        }

    }
    return temp;

}

From source file:com.samples.platform.service.iss.tech.support.GetSoapFaultOperation.java

/**
 * @param message//www  . j  a va 2  s. co m
 *            the {@link JAXBElement} containing a
 *            {@link GetSoapFaultRequestType}.
 * @return the {@link JAXBElement} with a {@link GetSoapFaultResponseType}.
 */
@InsightEndPoint
@ServiceActivator
public final JAXBElement<GetSoapFaultResponseType> getSoapFault(
        final JAXBElement<GetSoapFaultRequestType> message) {
    this.logger.debug("+getSoapFault");
    GetSoapFaultResponseType response = this.of.createGetSoapFaultResponseType();
    long start = System.currentTimeMillis();
    try {
        throw new RuntimeException("This RuntimeException need to last in a SOAP fault.");
    } catch (Throwable e) {
        this.logger.error(e.getMessage(), e);
        if ("a".equals("a")) {
            throw e;
        }
    } finally {
        this.logger.debug(" getSoapFault duration {}", DateUtil.getDuration(start, System.currentTimeMillis()));
        this.logger.debug("-getSoapFault #{}, #f{}", response/* .get() */ != null ? 1 : 0,
                response.getFailure().size());
    }
    return this.of.createGetSoapFaultResponse(response);
}

From source file:org.n52.web.ExceptionResponse.java

private String formatMessageOutput(Throwable causedBy) {
    return causedBy.getMessage().replace("\"", "'");
}

From source file:com.allogy.json.jackson.joda.ISODateTimeDeserializer.java

@Override
public DateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException, JsonProcessingException {
    String text = jsonParser.getText();
    try {/*from   ww  w  .j a v  a 2s.c o  m*/
        return dateTimeFormatter.parseDateTime(text);
    } catch (Throwable throwable) {
        throw new InvalidFormatException(throwable.getMessage(), text, String.class);
    }
}

From source file:com.allogy.json.jackson.joda.ISOLocalDateDeserializer.java

@Override
public LocalDate deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException, JsonProcessingException {
    String text = jsonParser.getText();
    try {/* w w  w  .j  a v a 2 s  .  co m*/
        return localDateFormatter.parseLocalDate(text);
    } catch (Throwable throwable) {
        throw new InvalidFormatException(throwable.getMessage(), text, String.class);
    }
}

From source file:com.alibaba.druid.support.ibatis.SpringIbatisBeanNameAutoProxyCreator.java

@SuppressWarnings("rawtypes")
protected Object createProxy(Class beanClass, String beanName, Object[] specificInterceptors,
        TargetSource targetSource) {//from  ww w  . j a  v a  2s .  c  o m
    try {
        Object target = targetSource.getTarget();

        if (target instanceof SqlMapClientWrapper) {
            proxyBeanNames.add(beanName);
            return target;
        }

        if (target instanceof SqlMapClient) {
            proxyBeanNames.add(beanName);

            return new SqlMapClientWrapper((ExtendedSqlMapClient) target);
        }

        return super.createProxy(beanClass, beanName, specificInterceptors, targetSource);
    } catch (Throwable ex) {
        LOG.error(ex.getMessage(), ex);
        return super.createProxy(beanClass, beanName, specificInterceptors, targetSource);
    }
}

From source file:com.qmetry.qaf.automation.ui.selenium.SubmitCommandListener.java

@Override
public void afterCommand(QAFCommandProcessor proc, SeleniumCommandTracker commandTracker) {
    if (commandTracker.getCommand().equalsIgnoreCase("submit") && (null != commandTracker.getArgs())
            && (commandTracker.getArgs().length > 0)) {
        log.info("Unable to submit field! trying by key press");

        try {// w  w  w .  ja va2s  .  c om
            if (commandTracker.hasException()) {
                proc.doCommand("keyPress", new String[] { commandTracker.getArgs()[0], "\\13" });
                commandTracker.setException(null);
            }
        } catch (Throwable t) {
            log.error(t.getMessage());
        }
    }
}

From source file:com.cubusmail.server.services.CubusmailServlet.java

@Override
public void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String fileName = request.getSession().getServletContext().getRealPath(request.getServletPath());
    BufferedReader reader = new BufferedReader(new FileReader(fileName));

    OutputStream outputStream = response.getOutputStream();
    OutputStreamWriter writer = new OutputStreamWriter(outputStream);
    char[] inBuf = new char[1024];
    int len = 0;/*from w  w w  . ja v  a  2  s  .  c om*/
    try {
        while ((len = reader.read(inBuf)) > 0) {
            writer.write(inBuf, 0, len);
        }
    } catch (Throwable e) {
        log.error(e.getMessage(), e);
    }

    writer.flush();
    writer.close();
    outputStream.flush();
    outputStream.close();
}