Search in sources :

Example 1 with TitusServiceException

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);
}
Also used : TitusServiceException(com.netflix.titus.api.service.TitusServiceException) Test(org.junit.Test)

Example 2 with TitusServiceException

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();
}
Also used : Status(io.grpc.Status) BadRequest(com.google.rpc.BadRequest) TitusServiceException(com.netflix.titus.api.service.TitusServiceException) DebugInfo(com.google.rpc.DebugInfo)

Example 3 with TitusServiceException

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);
}
Also used : TitusServiceException(com.netflix.titus.api.service.TitusServiceException) Test(org.junit.Test)

Aggregations

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