Skip to content
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
9 changes: 9 additions & 0 deletions src/main/java/com/retailsvc/http/ValidationException.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package com.retailsvc.http;

import com.retailsvc.http.validate.ValidationError;
import java.util.concurrent.atomic.AtomicLong;

public final class ValidationException extends RuntimeException {
/**
* Counts every {@code ValidationException} ever constructed. Used to assert that the validator
* does not use exceptions as control flow on the happy path: a successful validation of a body
* containing {@code oneOf}/{@code anyOf} branches should leave this counter unchanged.
*/
public static final AtomicLong CONSTRUCTIONS = new AtomicLong();

private final transient ValidationError error;

public ValidationException(ValidationError error) {
super(error.pointer() + " [" + error.keyword() + "] " + error.message());
this.error = error;
CONSTRUCTIONS.incrementAndGet();
}

public ValidationError error() {
Expand Down
Loading
Loading