Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ValidationException Immutable/Support Multi-Value Form Parameters. #270

Merged
merged 4 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 3 additions & 27 deletions http-api/src/main/java/io/avaje/http/api/ValidationException.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ public class ValidationException extends IllegalArgumentException {

private static final long serialVersionUID = 1L;

private int status = 422;
private final int status;

private List<Violation> errors;
private final List<Violation> errors;

/** Create with a message. */
public ValidationException(String message) {
super(message);
this.errors = new ArrayList<>();
status = 422;
}

/** Create with a status and message. */
Expand Down Expand Up @@ -52,21 +53,11 @@ public int getStatus() {
return status;
}

/** Set the suggested HTTP status to use in the response. */
public void setStatus(int status) {
this.status = status;
}

/** Return the errors typically as a map of field to error message. */
public List<Violation> getErrors() {
return errors;
}

/** Set the errors. */
public void setErrors(List<Violation> errors) {
this.errors = errors;
}

/** Error details including the field, error message and path */
public static class Violation implements Serializable {

Expand Down Expand Up @@ -101,20 +92,5 @@ public String getField() {
public String getMessage() {
return message;
}

SentryMan marked this conversation as resolved.
Show resolved Hide resolved
/** Set the path for this error. */
public void setPath(String path) {
this.path = path;
}

/** Set the field for this error. */
public void setField(String field) {
this.field = field;
}

/** Set the error message. */
public void setMessage(String message) {
this.message = message;
}
}
}
Loading