use of io.vertx.up.exception.WebException in project vertx-zero by silentbalanceyh.
the class MinLengthRuler 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 min = rule.getConfig().getInteger("min");
if (length < min) {
error = failure(field, value, rule);
}
return error;
}
use of io.vertx.up.exception.WebException in project vertx-zero by silentbalanceyh.
the class FileRigor method verify.
@Override
public WebException verify(final Map<String, List<Rule>> rulers, final Object body) {
WebException error = null;
if (!rulers.isEmpty()) {
// Merge rulers here.
final Set<Rule> rules = new HashSet<>();
Observable.fromIterable(rulers.keySet()).map(rulers::get).flatMap(Observable::fromIterable).subscribe(rules::add);
// Rules here.
error = Ruler.verify(rules, "BODY", body);
}
return error;
}
use of io.vertx.up.exception.WebException in project vertx-zero by silentbalanceyh.
the class Validator method replyError.
private <T> void replyError(final T proxy, final Method method, final ConstraintViolation<T> item) {
if (null != item) {
final WebException error = new _400ValidationException(this.getClass(), proxy.getClass(), method, item.getMessage());
error.setReadible(item.getMessage());
throw error;
}
}
use of io.vertx.up.exception.WebException in project vertx-zero by silentbalanceyh.
the class AuthenticateEndurer method handle.
@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();
}
}
use of io.vertx.up.exception.WebException in project vertx-zero by silentbalanceyh.
the class ServiceJet method reply405Error.
/**
* Method not Allowed ( 405 )
*
* @param context
*/
private void reply405Error(final RoutingContext context) {
final HttpServerRequest request = context.request();
final WebException exception = new _405MethodForbiddenException(getClass(), request.method(), request.uri());
Answer.reply(context, Envelop.failure(exception));
}
Aggregations