use of com.tvd12.ezyhttp.core.exception.DeserializeBodyException in project ezyhttp by youngmonkeys.
the class AbstractRequestHandler method deserializeBody.
protected <T> T deserializeBody(BodyData bodyData, Class<T> type) throws IOException {
String contentType = bodyData.getContentType();
if (contentType == null) {
throw new HttpBadRequestException("contentType is null");
}
BodyDeserializer deserializer = dataConverters.getBodyDeserializer(contentType);
try {
return deserializer.deserialize(bodyData, type);
} catch (Exception e) {
throw new DeserializeBodyException("can't deserialize body data to: " + type.getName(), e);
}
}
use of com.tvd12.ezyhttp.core.exception.DeserializeBodyException in project ezyhttp by youngmonkeys.
the class DeserializeBodyExceptionTest method test.
@Test
public void test() {
// given
Exception e = new Exception("just test");
// when
DeserializeBodyException sut = new DeserializeBodyException("hello", e);
// then
Asserts.assertEquals("hello", sut.getMessage());
Asserts.assertEquals(e, sut.getCause());
}
Aggregations