use of org.onosproject.net.config.InvalidFieldException in project onos by opennetworkinglab.
the class InvalidConfigExceptionMapper method response.
@Override
protected Response.ResponseBuilder response(Response.Status status, Throwable exception) {
error = exception;
InvalidConfigException ex = (InvalidConfigException) exception;
ObjectMapper mapper = new ObjectMapper();
String message = messageFrom(exception);
ObjectNode result = mapper.createObjectNode().put("code", status.getStatusCode()).put("message", message).put("subjectKey", ex.subjectKey()).put("subject", ex.subject()).put("configKey", ex.configKey());
if (ex.getCause() instanceof InvalidFieldException) {
InvalidFieldException fieldException = (InvalidFieldException) ex.getCause();
result.put("field", fieldException.field()).put("reason", fieldException.reason());
}
return Response.status(status).entity(result.toString());
}
Aggregations