use of com.fasterxml.jackson.core.JsonParseException in project underlx by underlx.
the class API method putTrip.
public Trip putTrip(TripRequest request) throws APIException {
try {
byte[] content = mapper.writeValueAsBytes(request);
InputStream is = putRequest(endpoint.resolve("trips"), content, true);
return mapper.readValue(is, Trip.class);
} catch (JsonParseException e) {
throw new APIException(e).addInfo("Parse exception");
} catch (JsonMappingException e) {
throw new APIException(e).addInfo("Mapping exception");
} catch (IOException e) {
throw new APIException(e).addInfo("IOException");
}
}
use of com.fasterxml.jackson.core.JsonParseException in project underlx by underlx.
the class API method postTrip.
public Trip postTrip(TripRequest request) throws APIException {
try {
byte[] content = mapper.writeValueAsBytes(request);
InputStream is = postRequest(endpoint.resolve("trips"), content, true);
return mapper.readValue(is, Trip.class);
} catch (JsonParseException e) {
throw new APIException(e).addInfo("Parse exception");
} catch (JsonMappingException e) {
throw new APIException(e).addInfo("Mapping exception");
} catch (IOException e) {
throw new APIException(e).addInfo("IOException");
}
}
use of com.fasterxml.jackson.core.JsonParseException in project jackson-core by FasterXML.
the class ParserErrorHandlingTest method _testMangledNumbersFloat.
private void _testMangledNumbersFloat(int mode) throws Exception {
// Also test with floats
JsonParser p = createParser(mode, "1.5false");
try {
JsonToken t = p.nextToken();
fail("Should have gotten an exception; instead got token: " + t);
} catch (JsonParseException e) {
verifyException(e, "expected space");
}
p.close();
}
use of com.fasterxml.jackson.core.JsonParseException in project jackson-core by FasterXML.
the class ParserErrorHandlingTest method _testMangledNumbersInt.
private void _testMangledNumbersInt(int mode) throws Exception {
JsonParser p = createParser(mode, "123true");
try {
JsonToken t = p.nextToken();
fail("Should have gotten an exception; instead got token: " + t);
} catch (JsonParseException e) {
verifyException(e, "expected space");
}
p.close();
}
use of com.fasterxml.jackson.core.JsonParseException in project jackson-core by FasterXML.
the class AsyncNumberCoercionTest method testToLongFailing.
public void testToLongFailing() throws Exception {
AsyncReaderWrapper p;
// BigInteger -> error
BigInteger big = BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.TEN);
p = createParser(String.valueOf(big));
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(NumberType.BIG_INTEGER, p.getNumberType());
assertEquals(big, p.getBigIntegerValue());
assertEquals(big, p.getNumberValue());
try {
p.getLongValue();
fail("Should not pass");
} catch (JsonParseException e) {
verifyException(e, "out of range of long");
}
BigInteger small = BigInteger.valueOf(Long.MIN_VALUE).subtract(BigInteger.TEN);
p = createParser(String.valueOf(small));
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(small, p.getBigIntegerValue());
try {
p.getLongValue();
fail("Should not pass");
} catch (JsonParseException e) {
verifyException(e, "out of range of long");
}
}
Aggregations