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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations