use of com.netflix.titus.api.service.TitusServiceException in project titus-control-plane by Netflix.
the class LoadBalancerResourceTest method removeLoadBalancerFailedTest.
@Test(expected = TitusServiceException.class)
public void removeLoadBalancerFailedTest() {
TitusServiceException exception = TitusServiceException.jobNotFound(TEST_JOB_ID);
when(loadBalancerService.removeLoadBalancer(any(), any())).thenReturn(Completable.error(exception));
loadBalancerResource.removeLoadBalancer(TEST_JOB_ID, TEST_LOAD_BALANCER_ID);
}
use of com.netflix.titus.api.service.TitusServiceException 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();
}
use of com.netflix.titus.api.service.TitusServiceException in project titus-control-plane by Netflix.
the class LoadBalancerResourceTest method addLoadBalancerFailedTest.
@Test(expected = TitusServiceException.class)
public void addLoadBalancerFailedTest() {
TitusServiceException exception = TitusServiceException.jobNotFound(TEST_JOB_ID);
when(loadBalancerService.addLoadBalancer(any(), any())).thenReturn(Completable.error(exception));
loadBalancerResource.addLoadBalancer(TEST_JOB_ID, TEST_LOAD_BALANCER_ID);
}
Aggregations