Example usage for java.lang Throwable Throwable

List of usage examples for java.lang Throwable Throwable

Introduction

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

Prototype

public Throwable(Throwable cause) 

Source Link

Document

Constructs a new throwable with the specified cause and a detail message of (cause==null ?

Usage

From source file:com.qubole.quark.plugins.jdbc.JdbcFactory.java

private DataSource getDataSource(Map<String, Object> properties, Class dbClass) throws QuarkException {
    try {/*from w  ww. jav  a2 s .  c  om*/
        return (DataSource) (dbClass.getConstructor(Map.class).newInstance(properties));
    } catch (NoSuchMethodException | IllegalAccessException | InstantiationException e) {
        throw new QuarkException(new Throwable("Invoking invalid constructor on class " + "specified for type "
                + properties.get("type") + ": " + dbClass.getCanonicalName()));
    } catch (InvocationTargetException e) {
        throw new QuarkException(e.getTargetException());
    }
}

From source file:fi.jumi.core.api.StackTraceTest.java

@Test
public void suppressed_exceptions_are_also_copied_recursively() {
    Throwable original = new Throwable("original message");
    original.addSuppressed(new Exception("suppressed 1"));
    original.addSuppressed(new RuntimeException("suppressed 2"));

    StackTrace copy = StackTrace.from(original);

    Throwable[] suppressed = copy.getSuppressed();
    assertThat(suppressed.length, is(2));
    assertThat(suppressed[0], is(instanceOf(StackTrace.class)));
    assertThat(suppressed[0].getMessage(), is("suppressed 1"));
    assertThat(suppressed[1], is(instanceOf(StackTrace.class)));
    assertThat(suppressed[1].getMessage(), is("suppressed 2"));
}

From source file:com.example.killnono.common.datacore.net.converter.maplist.JsonConverterFactory.java

@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
        Retrofit retrofit) {/*w  w  w  .j  a v  a2 s  .co  m*/
    TypeToken<?> typeToken = TypeToken.get(type);
    if (typeToken.getRawType() == JSONObject.class) {
        return new JsonResponseBodyConverter<JSONObject>();
    } else if (typeToken.getRawType() == JSONArray.class) {
        return new ListResponseBodyConverter<JSONArray>();
    } else {
        try {
            throw new Throwable("?");
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            return null;
        }
    }

}

From source file:com.example.killnono.common.datacore.net.converter.json.XJsonConverterFactory.java

@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
        Retrofit retrofit) {//ww w.j a  v  a2  s .c o m
    TypeToken<?> typeToken = TypeToken.get(type);
    if (typeToken.getRawType() == JSONObject.class) {
        return new JsonResponseBodyConverter<JSONObject>();
    } else if (typeToken.getRawType() == JSONArray.class) {
        return new JsonArrayResponseBodyConverter<JSONArray>();
    } else {
        try {
            throw new Throwable("?");
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            return null;
        }
    }

}

From source file:de.tudarmstadt.ukp.dkpro.keyphrases.bookindexing.evaluation.phrasematch.TokenReader.java

@Override
public List<String> getListOfStrings(final JCas jcas) throws AnalysisEngineProcessException {
    String goldPhrases;//from  w w w  . ja  v  a  2  s. c  om
    try {
        goldPhrases = FileUtils.readFileToString(
                new File(FilenameUtils.concat(path, getDocumentBaseName(jcas) + normalizeSuffix(suffix))));
    } catch (final IOException e) {
        throw new AnalysisEngineProcessException(new Throwable(e));
    }

    final List<String> result = new ArrayList<String>();

    for (String goldPhrase : goldPhrases.split(delimiter)) {
        goldPhrase = lowercase ? goldPhrase.toLowerCase() : goldPhrase;
        goldPhrase = goldPhrase.trim();
        if (!goldPhrase.isEmpty())
            result.add(goldPhrase);
    }

    return result;
}

From source file:org.sonatype.siesta.webapp.test.TestResource.java

@GET
@Path("ping")
@Produces(TEXT_PLAIN)//from ww  w.ja va2s  .c  om
public String ping(final @QueryParam("text") @DefaultValue("pong") String text) {
    if (log.isTraceEnabled()) {
        log.trace("PING", new Throwable("MARKER"));
    } else {
        log.debug("PING");
    }

    return text;
}

From source file:io.openkit.OKHTTPClient.java

public static void postJSON(String relativeUrl, JSONObject requestParams,
        AsyncHttpResponseHandler responseHandler) {
    StringEntity sEntity = getJSONString(requestParams);
    HttpPost request = new HttpPost(getAbsoluteUrl(relativeUrl));

    if (sEntity == null) {
        responseHandler.onFailure(new Throwable("JSON encoding error"), "JSON encoding error");
    } else {//from  w  ww.  j a  va2s .  c om
        request.setEntity(sEntity);
        sign(request);
        client.post(request, "application/json", responseHandler);
    }
}

From source file:cz.muni.fi.sport.club.sport.club.rest.AgeGroupsResource.java

@GET
@Path("/all")
@Produces(MediaType.APPLICATION_JSON)//  www  .  j  a v a2 s.c  o  m
public List<AgeGroup> getAll() throws WebApplicationException {
    try {
        List<AgeGroupDTO> result = ageGroupService.getAllAgeGroups();
        return AgeGroupMapping.listToEntity(result);

    } catch (Exception ex) {
        throw new WebApplicationException(new Throwable("We apologize for internal server error"),
                Response.Status.INTERNAL_SERVER_ERROR);
    }
}

From source file:de.tudarmstadt.ukp.dkpro.tc.testing.TestPairReader.java

@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
    super.initialize(context);

    fileOffset = 0;//from   w w  w.  ja v a2 s  . c  o  m
    texts1 = new ArrayList<String>();
    texts2 = new ArrayList<String>();

    try {
        for (String line : FileUtils.readLines(inputFile)) {
            String parts[] = line.split("\t");

            if (parts.length != 2) {
                throw new ResourceInitializationException(new Throwable("Wrong file format: " + line));
            }

            texts1.add(parts[0]);
            texts2.add(parts[1]);
        }
    } catch (IOException e) {
        throw new ResourceInitializationException(e);
    }
}

From source file:com.tesora.dve.sql.util.JdbcConnectionResourceResponse.java

@Override
public void assertEqualResponse(String cntxt, ResourceResponse other) throws Throwable {
    if (results != null) {
        // result set, not much we can do
    } else if (other instanceof JdbcConnectionResourceResponse) {
        JdbcConnectionResourceResponse othResp = (JdbcConnectionResourceResponse) other;
        assertEquals(cntxt + " row count", updateCount, othResp.updateCount);
    } else if (other instanceof ProxyConnectionResourceResponse) {
        ProxyConnectionResourceResponse othResp = (ProxyConnectionResourceResponse) other;
        assertEquals(cntxt + " row count", updateCount, new Long(othResp.getNumRowsAffected()));
    } else if (other == null) {
        // if the other side is null - that's a problem
        fail("missing other response");
    } else {/*from ww  w  . ja  v a  2s.  co m*/
        throw new Throwable("What kind of ResourceResponse is " + other.getClass().getName());
    }
}