Search in sources :

Example 11 with WebException

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

the class ListObstain method unique.

@Override
public ListObstain<T> unique() {
    final WebException error404 = Instance.instance(_404RecordNotFoundException.class, this.clazz);
    final WebException error400 = Instance.instance(_400DuplicatedRecordException.class, this.clazz);
    return unique(error404, error400);
}
Also used : WebException(io.vertx.up.exception.WebException)

Example 12 with WebException

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

the class BaseAim method success.

protected Envelop success(final String address, final AsyncResult<Message<Envelop>> handler) {
    Envelop envelop;
    try {
        final Message<Envelop> message = handler.result();
        envelop = message.body();
    } catch (final Throwable ex) {
        final WebException error = new _500EntityCastException(this.getClass(), address, ex.getMessage());
        envelop = Envelop.failure(error);
    }
    return envelop;
}
Also used : io.vertx.up.exception._500EntityCastException(io.vertx.up.exception._500EntityCastException) WebException(io.vertx.up.exception.WebException) Envelop(io.vertx.up.atom.Envelop)

Example 13 with WebException

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

the class JObjectRigor method verify.

@Override
public WebException verify(final Map<String, List<Rule>> rulers, final Object body) {
    WebException error = null;
    if (!rulers.isEmpty()) {
        // Extract first element to JsonObject
        if (null != body) {
            final JsonObject data = (JsonObject) body;
            // Verify the whole JsonObject
            for (final String field : rulers.keySet()) {
                final Object value = data.getValue(field);
                final List<Rule> rules = rulers.get(field);
                // Verify each field.
                error = Ruler.verify(rules, field, value);
                if (null != error) {
                    break;
                }
            }
        }
    }
    return error;
}
Also used : WebException(io.vertx.up.exception.WebException) JsonObject(io.vertx.core.json.JsonObject) JsonObject(io.vertx.core.json.JsonObject) Rule(io.vertx.up.atom.Rule)

Example 14 with WebException

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

the class Flower method verifyPureArguments.

private static WebException verifyPureArguments(final Validator verifier, final Depot depot, final Object[] args) {
    final Event event = depot.getEvent();
    final Object proxy = event.getProxy();
    final Method method = event.getAction();
    WebException error = null;
    try {
        if (Virtual.is(proxy)) {
        // TODO: Wait for proxy generation
        // Validation for dynamic proxy
        // final Object delegate = Instance.getProxy(method);
        // verifier.verifyMethod(delegate, method, args);
        } else {
            // Validation for proxy
            verifier.verifyMethod(proxy, method, args);
        }
    } catch (final WebException ex) {
        // Basic validation failure
        error = ex;
    }
    return error;
}
Also used : WebException(io.vertx.up.exception.WebException) Event(io.vertx.up.atom.agent.Event) Method(java.lang.reflect.Method)

Example 15 with WebException

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

the class MaxLengthRuler method verify.

@Override
public WebException verify(final String field, final Object value, final Rule rule) {
    WebException error = null;
    final int length = null == value ? Values.ZERO : value.toString().length();
    final int max = rule.getConfig().getInteger("max");
    if (length > max) {
        error = failure(field, value, rule);
    }
    return error;
}
Also used : WebException(io.vertx.up.exception.WebException)

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