Search in sources :

Example 16 with WebException

use of io.vertx.up.exception.WebException in project vertx-zero by silentbalanceyh.

the class Fluctuate method thenOtherwise.

static <T, R> Future<R> thenOtherwise(final Future<Boolean> conditionFuture, final Supplier<Future<T>> supplierTrue, final Function<T, R> trueFun, final Class<? extends WebException> clazz, final Object... args) {
    final Future<R> future = Future.future();
    conditionFuture.setHandler(handler -> {
        if (handler.succeeded() && handler.result()) {
            // Success & Boolean
            final Future<T> trueFuture = supplierTrue.get();
            trueFuture.setHandler(trueRes -> future.complete(trueFun.apply(trueRes.result())));
        } else {
            // Failed & Boolean = false;
            if (null == clazz) {
                future.complete();
            } else {
                // Error existing
                final WebException error = Instance.instance(clazz, args);
                future.fail(error);
            }
        }
    });
    return future;
}
Also used : WebException(io.vertx.up.exception.WebException)

Example 17 with WebException

use of io.vertx.up.exception.WebException in project vertx-zero by silentbalanceyh.

the class ErrorTc method buildError.

@Test
public void buildError() {
    final WebException error = new _500InternalServerException(this.getClass(), "Error Internal");
    System.out.println(error);
    Assert.assertNotNull(error);
}
Also used : WebException(io.vertx.up.exception.WebException) io.vertx.up.exception._500InternalServerException(io.vertx.up.exception._500InternalServerException) Test(org.junit.Test)

Aggregations

WebException (io.vertx.up.exception.WebException)17 JsonObject (io.vertx.core.json.JsonObject)2 Rule (io.vertx.up.atom.Rule)2 Envelop (io.vertx.up.atom.Envelop)1 Event (io.vertx.up.atom.agent.Event)1 io.vertx.up.exception._400ValidationException (io.vertx.up.exception._400ValidationException)1 io.vertx.up.exception._400ValidationRuleException (io.vertx.up.exception._400ValidationRuleException)1 io.vertx.up.exception._404ServiceNotFoundException (io.vertx.up.exception._404ServiceNotFoundException)1 io.vertx.up.exception._405MethodForbiddenException (io.vertx.up.exception._405MethodForbiddenException)1 io.vertx.up.exception._500EntityCastException (io.vertx.up.exception._500EntityCastException)1 io.vertx.up.exception._500InternalServerException (io.vertx.up.exception._500InternalServerException)1 Rigor (io.vertx.up.rs.announce.Rigor)1 Method (java.lang.reflect.Method)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1