// check for errors
if (event.has("error")) {
ObjectNode error = (ObjectNode)event.get("error");
Integer code = error.has("code") ? error.get("code").asInt() : null;
if (code != null && (code.equals(404) || code.equals(410))) {
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 (event.has("status") && event.get("status").asText().equals("cancelled")) {
throw new JSONRPCException(CODE.NOT_FOUND);
}
return event;
}