All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.up.uca.web.failure.AuthenticateEndurer Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package io.vertx.up.uca.web.failure;

import io.vertx.core.Handler;
import io.vertx.ext.web.RoutingContext;
import io.vertx.up.commune.Envelop;
import io.vertx.up.exception.WebException;
import io.vertx.up.uca.rs.hunt.Answer;

/**
 * Common handler to handle failure
 */
public class AuthenticateEndurer implements Handler {

    public static Handler create() {
        return new AuthenticateEndurer();
    }

    private AuthenticateEndurer() {
    }

    @Override
    public void handle(final RoutingContext event) {
        if (event.failed()) {
            final Throwable ex = event.failure();
            if (ex instanceof WebException) {
                final WebException error = (WebException) ex;
                Answer.reply(event, Envelop.failure(error));
            } else {
                // Other exception found
                event.fail(ex);
            }
        } else {
            // Success, do not throw, continue to request
            event.next();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy