Search in sources :

Example 1 with DebugInfo

use of com.google.rpc.DebugInfo in project titus-control-plane by Netflix.

the class GrpcExceptionMapper method buildRpcStatus.

private com.google.rpc.Status buildRpcStatus(Throwable exception, int errorCode) {
    com.google.rpc.Status.Builder builder = com.google.rpc.Status.newBuilder().setCode(errorCode).setMessage(getNonNullMessage(exception));
    DebugInfo debugInfo = DebugInfo.newBuilder().addAllStackEntries(stream(exception.getStackTrace()).map(StackTraceElement::toString).collect(Collectors.toList())).build();
    builder.addDetails(Any.pack(debugInfo));
    return builder.build();
}
Also used : Status(io.grpc.Status) DebugInfo(com.google.rpc.DebugInfo)

Example 2 with DebugInfo

use of com.google.rpc.DebugInfo in project titus-control-plane by Netflix.

the class ErrorResponses method buildRpcStatus.

private static com.google.rpc.Status buildRpcStatus(Throwable exception, int errorCode) {
    com.google.rpc.Status.Builder builder = com.google.rpc.Status.newBuilder().setCode(errorCode).setMessage(getNonNullMessage(exception));
    DebugInfo debugInfo = DebugInfo.newBuilder().addAllStackEntries(stream(exception.getStackTrace()).map(StackTraceElement::toString).collect(Collectors.toList())).build();
    builder.addDetails(Any.pack(debugInfo));
    if (exception instanceof TitusServiceException) {
        TitusServiceException e = (TitusServiceException) exception;
        if (!e.getValidationErrors().isEmpty()) {
            BadRequest.Builder rbuilder = BadRequest.newBuilder();
            e.getValidationErrors().forEach(v -> {
                BadRequest.FieldViolation.Builder fbuilder = BadRequest.FieldViolation.newBuilder();
                fbuilder.setField(v.getField());
                fbuilder.setDescription(v.getDescription());
                rbuilder.addFieldViolations(fbuilder.build());
            });
            builder.addDetails(Any.pack(rbuilder.build()));
        }
    }
    return builder.build();
}
Also used : Status(io.grpc.Status) BadRequest(com.google.rpc.BadRequest) TitusServiceException(com.netflix.titus.api.service.TitusServiceException) DebugInfo(com.google.rpc.DebugInfo)

Aggregations

DebugInfo (com.google.rpc.DebugInfo)2 Status (io.grpc.Status)2 BadRequest (com.google.rpc.BadRequest)1 TitusServiceException (com.netflix.titus.api.service.TitusServiceException)1