@Override
public void writeResponse(final Object entity, final RouteContext routeContext) throws Exception {
if (entity instanceof ErrorResponse) {
final ErrorResponse errorResponse = (ErrorResponse) entity;
routeContext.getResponse().setStatus(errorResponse.statusCode());
writeJsonResponse(errorResponse.content(), routeContext);
} else {
if (entity != null) {
writeJsonResponse(entity, routeContext);
}
}