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();
}
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();
}
Aggregations