Search in sources :

Example 1 with RenderContent

use of org.webpieces.router.api.controller.actions.RenderContent in project webpieces by deanhiller.

the class JacksonCatchAllFilter method translateError.

protected RenderContent translateError(Throwable t) {
    byte[] content = translateServerError(t);
    KnownStatusCode status = KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR;
    return new RenderContent(content, status.getCode(), status.getReason(), MIME_TYPE);
}
Also used : RenderContent(org.webpieces.router.api.controller.actions.RenderContent) KnownStatusCode(org.webpieces.httpparser.api.dto.KnownStatusCode)

Example 2 with RenderContent

use of org.webpieces.router.api.controller.actions.RenderContent in project webpieces by deanhiller.

the class JacksonCatchAllFilter method translate.

protected Action translate(MethodMeta meta, HttpException t) {
    byte[] content = translateHttpException(meta, t);
    StatusCode status = t.getStatusCode();
    String msg = "Error";
    int code = t.getHttpCode();
    if (status != null)
        msg = status.getReason();
    return new RenderContent(content, code, msg, MIME_TYPE);
}
Also used : RenderContent(org.webpieces.router.api.controller.actions.RenderContent) StatusCode(org.webpieces.http.StatusCode) KnownStatusCode(org.webpieces.httpparser.api.dto.KnownStatusCode)

Example 3 with RenderContent

use of org.webpieces.router.api.controller.actions.RenderContent in project webpieces by deanhiller.

the class GrpcJsonCatchAllFilter method translateError.

protected RenderContent translateError(Throwable t) {
    Builder builder = ErrorResponse.newBuilder();
    builder.setError("Server ran into a bug, please report");
    builder.setCode(500);
    byte[] content = translateJson(builder);
    KnownStatusCode status = KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR;
    return new RenderContent(content, status.getCode(), status.getReason(), MIME_TYPE);
}
Also used : Builder(org.webpieces.grpc.ErrorResponse.Builder) MessageOrBuilder(com.google.protobuf.MessageOrBuilder) RenderContent(org.webpieces.router.api.controller.actions.RenderContent) KnownStatusCode(org.webpieces.httpparser.api.dto.KnownStatusCode)

Example 4 with RenderContent

use of org.webpieces.router.api.controller.actions.RenderContent in project webpieces by deanhiller.

the class GrpcJsonCatchAllFilter method translate.

protected Action translate(ForbiddenException t) {
    Builder builder = ErrorResponse.newBuilder();
    builder.setError(t.getHttpCode() + " " + t.getStatusMessage() + ": " + t.getMessage());
    builder.setCode(t.getHttpCode());
    byte[] content = translateJson(builder);
    KnownStatusCode status = KnownStatusCode.HTTP_401_UNAUTHORIZED;
    return new RenderContent(content, status.getCode(), status.getReason(), MIME_TYPE);
}
Also used : Builder(org.webpieces.grpc.ErrorResponse.Builder) MessageOrBuilder(com.google.protobuf.MessageOrBuilder) RenderContent(org.webpieces.router.api.controller.actions.RenderContent) KnownStatusCode(org.webpieces.httpparser.api.dto.KnownStatusCode)

Example 5 with RenderContent

use of org.webpieces.router.api.controller.actions.RenderContent in project webpieces by deanhiller.

the class GrpcJsonCatchAllFilter method translate.

protected RenderContent translate(BadRequestException t) {
    Builder builder = ErrorResponse.newBuilder();
    builder.setError(t.getHttpCode() + " " + t.getStatusMessage() + ": " + t.getMessage());
    builder.setCode(t.getHttpCode());
    byte[] content = translateJson(builder);
    KnownStatusCode status = KnownStatusCode.HTTP_400_BADREQUEST;
    return new RenderContent(content, status.getCode(), status.getReason(), MIME_TYPE);
}
Also used : Builder(org.webpieces.grpc.ErrorResponse.Builder) MessageOrBuilder(com.google.protobuf.MessageOrBuilder) RenderContent(org.webpieces.router.api.controller.actions.RenderContent) KnownStatusCode(org.webpieces.httpparser.api.dto.KnownStatusCode)

Aggregations

RenderContent (org.webpieces.router.api.controller.actions.RenderContent)7 KnownStatusCode (org.webpieces.httpparser.api.dto.KnownStatusCode)6 MessageOrBuilder (com.google.protobuf.MessageOrBuilder)5 Builder (org.webpieces.grpc.ErrorResponse.Builder)5 StatusCode (org.webpieces.http.StatusCode)1