// check for errors
if (task.has("error")) {
ObjectNode error = (ObjectNode)task.get("error");
Integer code = error.has("code") ? error.get("code").asInt() : null;
if (code != null && code.equals(404)) {
throw new JSONRPCException(CODE.NOT_FOUND);
}
throw new JSONRPCException(error);
}
// check if canceled. If so, return null
// TODO: be able to retrieve canceled events?
if (task.has("status") && task.get("status").asText().equals("cancelled")) {
throw new JSONRPCException(CODE.NOT_FOUND);
}
return task;
}