use of io.vertx.up.exception.WebException in project vertx-zero by silentbalanceyh.
the class ServiceJet method reply404Error.
/**
* Service Not Found ( 404 )
*
* @param context
*/
private void reply404Error(final RoutingContext context) {
final HttpServerRequest request = context.request();
final WebException exception = new _404ServiceNotFoundException(getClass(), request.uri(), request.method());
Answer.reply(context, Envelop.failure(exception));
}
use of io.vertx.up.exception.WebException in project vertx-zero by silentbalanceyh.
the class Flower method executeRequest.
static void executeRequest(final RoutingContext context, final Map<String, List<Rule>> rulers, final Depot depot, final Object[] args, final Validator verifier) {
// Extract major object
final WebException error = verifyPureArguments(verifier, depot, args);
if (null == error) {
// Check if annotated with @Codex
final KeyPair<Integer, Class<?>> found = Anno.findParameter(depot.getEvent().getAction(), Codex.class);
if (null == found.getValue()) {
context.next();
} else {
// @Codex validation for different types
final Class<?> type = found.getValue();
final Object value = args[found.getKey()];
verifyCodex(context, rulers, depot, type, value);
}
} else {
// Hibernate validate failure
replyError(context, error, depot.getEvent());
}
}
use of io.vertx.up.exception.WebException in project vertx-zero by silentbalanceyh.
the class Flower method verifyCodex.
private static void verifyCodex(final RoutingContext context, final Map<String, List<Rule>> rulers, final Depot depot, final Class<?> type, final Object value) {
final Rigor rigor = Rigor.get(type);
if (null == rigor) {
LOGGER.warn(Info.RIGOR_NOT_FOUND, type);
context.next();
} else {
final WebException error = rigor.verify(rulers, value);
if (null == error) {
// Ignore Errors
context.next();
} else {
// Reply Error
replyError(context, error, depot.getEvent());
}
}
}
use of io.vertx.up.exception.WebException in project vertx-zero by silentbalanceyh.
the class BaseRuler method failure.
protected WebException failure(final String field, final Object value, final Rule rule) {
final String message = rule.getMessage();
final WebException error = new _400ValidationRuleException(getClass(), field, value, message);
error.setReadible(message);
getLogger().info(Info.MSG_FAILURE, error.toJson());
return error;
}
use of io.vertx.up.exception.WebException in project vertx-zero by silentbalanceyh.
the class LengthRuler method verify.
@Override
public WebException verify(final String field, final Object value, final Rule rule) {
WebException error = null;
// Extract length
final JsonObject config = rule.getConfig();
if (config.containsKey("max")) {
final Ruler ruler = Ruler.get("maxlength");
error = ruler.verify(field, value, rule);
}
if (null == error && config.containsKey("min")) {
final Ruler ruler = Ruler.get("minlength");
error = ruler.verify(field, value, rule);
}
return error;
}
Aggregations