public static void returnError(RakamHttpRequest request, String msg, HttpResponseStatus status) { ByteBuf byteBuf = Unpooled.wrappedBuffer(JsonHelper.encodeAsBytes(errorMessage(msg, status))); DefaultFullHttpResponse errResponse = new DefaultFullHttpResponse(HTTP_1_1, status, byteBuf); setBrowser(request, errResponse); request.response(errResponse).end(); }
LOGGER.error(new RuntimeException(sample.toString(), e), "Error executing EventStore " + (single ? "store" : "batch") + " method."); return completedFuture(new HeaderDefaultFullHttpResponse(HTTP_1_1, INTERNAL_SERVER_ERROR, Unpooled.wrappedBuffer(encodeAsBytes(errorMessage("An error occurred", INTERNAL_SERVER_ERROR))), responseHeaders));
"Error while storing event."); return new HeaderDefaultFullHttpResponse(HTTP_1_1, INTERNAL_SERVER_ERROR, Unpooled.wrappedBuffer(encodeAsBytes(errorMessage("An error occurred", INTERNAL_SERVER_ERROR))), responseHeaders);
@Path("/listen") @GET @ApiImplicitParams({ @ApiImplicitParam(name = "project", dataType = "string", paramType = "query"), }) @ApiOperation(value = "Listen all mailboxes", consumes = "text/event-stream", produces = "text/event-stream", authorizations = @Authorization(value = "read_key") ) @IgnoreApi public void listenMails(RakamHttpRequest request) { RakamHttpRequest.StreamResponse response = request.streamResponse(); List<String> apiKey = request.params().get("api_key"); if (apiKey == null || apiKey.isEmpty()) { response.send("result", encode(HttpServer.errorMessage("api_key query parameter is required", HttpResponseStatus.BAD_REQUEST))).end(); return; } List<String> api_key = request.params().get("read_key"); String project = apiKeyService.getProjectOfApiKey(api_key.get(0), ApiKeyService.AccessKeyType.READ_KEY); UserMailboxStorage.MessageListener update = storage.listenAllUsers(project, data -> response.send("update", data.serialize())); response.listenClose(() -> update.shutdown()); }
data = request.params().get("data"); } catch (Exception e) { response.send("result", encode(errorMessage("enable to parse data parameter: " + e.getMessage(), BAD_REQUEST))).end(); return; response.send("result", encode(errorMessage("data query parameter is required", BAD_REQUEST))).end(); return; query = JsonHelper.readSafe(data.get(0), clazz); } catch (Exception e) { response.send("result", encode(errorMessage("JSON couldn't parsed: " + e.getMessage(), BAD_REQUEST))).end(); return; String message = keyType.getKey() + " query parameter is required"; LogUtil.logException(request, new RakamException(message, BAD_REQUEST)); response.send("result", encode(errorMessage(message, BAD_REQUEST))).end(); return; } catch (RakamException e) { if (e.getStatusCode() == FORBIDDEN) { response.send("result", encode(errorMessage(e.getMessage(), FORBIDDEN))).end(); } else { response.send("result", encode(errorMessage(e.getMessage(), e.getStatusCode()))).end(); } catch (RakamException e) { LogUtil.logException(request, e); response.send("result", encode(errorMessage("Couldn't execute query: " + e.getMessage(), BAD_REQUEST))).end(); return; } catch (Exception e) {
response.send("error", encode(errorMessage("data query parameter is required", BAD_REQUEST))).end(); return; query = JsonHelper.readSafe(data.get(0), StreamQuery.class); } catch (IOException e) { response.send("error", encode(errorMessage("JSON couldn't parsed: " + e.getMessage(), BAD_REQUEST))); return; expression = collection.filter == null ? null : sqlParser.createExpression(collection.filter); } catch (ParsingException e) { request.response(encode(errorMessage(format("Couldn't parse %s: %s", collection.filter, e.getErrorMessage()), BAD_REQUEST))).end(); throw e;
Unpooled.wrappedBuffer(encodeAsBytes(errorMessage("An error occurred: " + e.getMessage(), INTERNAL_SERVER_ERROR))), responseHeaders);
request.response(JsonHelper.encode(errorMessage("An error occurred", INTERNAL_SERVER_ERROR)), INTERNAL_SERVER_ERROR); LOGGER.error(ex, "Error while performing batch user operation");
@Override public void operationComplete(Future<Object> future) throws Exception { if (future.await(1, TimeUnit.SECONDS)) { Object body = future.getNow(); if (body == null) { return; } if (!(body instanceof ScriptObjectMirror)) { returnError(request, "The script must return an object or array {collection: '', properties: {}}", BAD_REQUEST); } ScriptObjectMirror json = (ScriptObjectMirror) ((ScriptObjectMirror) body).eval("JSON"); Object stringify = json.callMember("stringify", body); request.response(stringify.toString()).end(); } else { byte[] bytes = JsonHelper.encodeAsBytes(errorMessage("Webhook code timeouts.", INTERNAL_SERVER_ERROR)); request.response(bytes, INTERNAL_SERVER_ERROR).end(); } } });
byte[] bytes = JsonHelper.encodeAsBytes(errorMessage("Webhook code timeouts.", INTERNAL_SERVER_ERROR));
String message = "Error while processing event mappers"; LOGGER.error(ex, message); request.response(JsonHelper.encode(errorMessage(message, INTERNAL_SERVER_ERROR)), INTERNAL_SERVER_ERROR); } else {