use of rx.exceptions.CompositeException in project azure-sdk-for-java by Azure.
the class LoadBalancerImpl method afterCreating.
@Override
protected void afterCreating() {
List<Exception> nicExceptions = new ArrayList<>();
// Update the NICs to point to the backend pool
for (Entry<String, String> nicInBackend : this.nicsInBackends.entrySet()) {
String nicId = nicInBackend.getKey();
String backendName = nicInBackend.getValue();
try {
NetworkInterface nic = this.manager().networkInterfaces().getById(nicId);
NicIPConfiguration nicIP = nic.primaryIPConfiguration();
nic.update().updateIPConfiguration(nicIP.name()).withExistingLoadBalancerBackend(this, backendName).parent().apply();
} catch (Exception e) {
nicExceptions.add(e);
}
}
if (!nicExceptions.isEmpty()) {
throw new CompositeException(nicExceptions);
}
this.nicsInBackends.clear();
this.refresh();
}
use of rx.exceptions.CompositeException in project azure-sdk-for-java by Azure.
the class ExternalChildResourceTests method shouldEmitErrorAfterAllSuccessfulCommit.
@Test
public void shouldEmitErrorAfterAllSuccessfulCommit() throws InterruptedException {
// Parent resource
ChickenImpl chicken = new ChickenImpl();
chicken.defineNewPullet("alice").withAge(1).withFailFlag(PulletImpl.FailFlag.OnCreate).attach().updatePullet("Clover").withAge(2).parent().updatePullet("Goldilocks").withAge(2).withFailFlag(PulletImpl.FailFlag.OnUpdate).parent().withoutPullet("Pinky");
final List<PulletImpl> changedPuppets = new ArrayList<>();
final List<Throwable> throwables = new ArrayList<>();
final CountDownLatch monitor = new CountDownLatch(1);
PulletsImpl pullets = chicken.pullets();
pullets.commitAsync().subscribe(new Observer<PulletImpl>() {
@Override
public void onCompleted() {
monitor.countDown();
Assert.assertTrue("onCompleted should not be invoked", false);
}
@Override
public void onError(Throwable throwable) {
try {
CompositeException exception = (CompositeException) throwable;
Assert.assertNotNull(exception);
for (Throwable innerThrowable : exception.getExceptions()) {
throwables.add(innerThrowable);
}
} finally {
monitor.countDown();
}
}
@Override
public void onNext(PulletImpl pullet) {
changedPuppets.add(pullet);
}
});
monitor.await();
Assert.assertTrue(throwables.size() == 2);
Assert.assertTrue(changedPuppets.size() == 2);
}
use of rx.exceptions.CompositeException in project retrofit by square.
the class CallArbiter method deliverResponse.
private void deliverResponse(Response<T> response) {
try {
if (!isUnsubscribed()) {
subscriber.onNext(response);
}
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
try {
subscriber.onError(t);
} catch (Throwable inner) {
Exceptions.throwIfFatal(inner);
CompositeException composite = new CompositeException(t, inner);
RxJavaPlugins.getInstance().getErrorHandler().handleError(composite);
}
return;
}
try {
subscriber.onCompleted();
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
RxJavaPlugins.getInstance().getErrorHandler().handleError(t);
}
}
Aggregations