use of com.fasterxml.jackson.databind.exc.InvalidDefinitionException in project jackson-databind by FasterXML.
the class SerializerProvider method reportBadDefinition.
/**
* @since 2.9
*/
public <T> T reportBadDefinition(JavaType type, String msg, Throwable cause) throws JsonMappingException {
InvalidDefinitionException e = InvalidDefinitionException.from(getGenerator(), msg, type);
e.initCause(cause);
throw e;
}
use of com.fasterxml.jackson.databind.exc.InvalidDefinitionException in project jackson-databind by FasterXML.
the class SerializerProvider method reportBadDefinition.
/**
* @since 2.9
*/
public <T> T reportBadDefinition(Class<?> raw, String msg, Throwable cause) throws JsonMappingException {
InvalidDefinitionException e = InvalidDefinitionException.from(getGenerator(), msg, constructType(raw));
e.initCause(cause);
throw e;
}
use of com.fasterxml.jackson.databind.exc.InvalidDefinitionException in project dropwizard by dropwizard.
the class JsonProcessingExceptionMapper method toResponse.
@Override
public Response toResponse(JsonProcessingException exception) {
/*
* If the error is in the JSON generation or an invalid definition, it's a server error.
*/
if (exception instanceof JsonGenerationException || exception instanceof InvalidDefinitionException) {
// LoggingExceptionMapper will log exception
return super.toResponse(exception);
}
/*
* Otherwise, it's those pesky users.
*/
logger.debug("Unable to process JSON", exception);
final String message = exception.getOriginalMessage();
final ErrorMessage errorMessage = new ErrorMessage(Response.Status.BAD_REQUEST.getStatusCode(), "Unable to process JSON", showDetails ? message : null);
return Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON_TYPE).entity(errorMessage).build();
}
use of com.fasterxml.jackson.databind.exc.InvalidDefinitionException in project jackson-databind by FasterXML.
the class DeserializationContext method instantiationException.
/**
* Helper method for constructing instantiation exception for specified type,
* to indicate problem with physically constructing instance of
* specified class (missing constructor, exception from constructor)
*<p>
* Note that most of the time this method should NOT be called; instead,
* {@link #handleInstantiationProblem} should be called which will call this method
* if necessary.
*/
public JsonMappingException instantiationException(Class<?> instClass, Throwable cause) {
// Most likely problem with Creator definition, right?
JavaType type = constructType(instClass);
String msg = String.format("Can not construct instance of %s, problem: %s", ClassUtil.nameOf(instClass), cause.getMessage());
InvalidDefinitionException e = InvalidDefinitionException.from(_parser, msg, type);
e.initCause(cause);
return e;
}
Aggregations