
io.vertx.ext.web.validation.BadRequestException Maven / Gradle / Ivy
package io.vertx.ext.web.validation;
import io.vertx.core.VertxException;
import io.vertx.core.json.JsonObject;
/**
* Represents an exception while processing a request with {@link ValidationHandler}. Possible failures could be:
*
* - {@link ParameterProcessorException}: Failure while processing the request parameter
* - {@link BodyProcessorException}: Failure while processing the request body
* - {@link RequestPredicateException}: A request predicate doesn't match
*
*/
public abstract class BadRequestException extends VertxException {
public BadRequestException(String message, Throwable cause) {
super("[Bad Request] " + message, cause);
}
/**
* Returns a Json representation of the exception
*
* @return
*/
public JsonObject toJson() {
JsonObject res = new JsonObject()
.put("type", this.getClass().getSimpleName())
.put("message", this.getMessage());
if (this.getCause() != null) {
res
.put("causeType", this.getCause().getClass().getSimpleName())
.put("causeMessage", this.getCause().getMessage());
}
return res;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy