@@ -32,16 +32,18 @@ public class ValidationException extends RuntimeException {
32
32
* create {@code ValidationException}s, handling the case of multiple violations occuring during
33
33
* validation.
34
34
*
35
- * <p>
36
35
* <ul>
37
36
* <li>If {@code failures} is empty, then it doesn't do anything</li>
38
37
* <li>If {@code failures} contains 1 exception instance, then that will be thrown</li>
39
38
* <li>Otherwise a new exception instance will be created, its {@link #getViolatedSchema()
40
39
* violated schema} will be {@code rootFailingSchema}, and its {@link #getCausingExceptions()
41
40
* causing exceptions} will be the {@code failures} list</li>
42
41
* </ul>
43
- * </p>
44
42
*
43
+ * @param rootFailingSchema
44
+ * the schema which detected the {@code failures}
45
+ * @param failures
46
+ * list containing validation failures to be thrown by this method
45
47
*/
46
48
public static void throwFor (final Schema rootFailingSchema ,
47
49
final List <ValidationException > failures ) {
@@ -63,6 +65,11 @@ public static void throwFor(final Schema rootFailingSchema,
63
65
64
66
/**
65
67
* Deprecated, use {@code ValidationException(Schema, Class<?>, Object)} instead.
68
+ *
69
+ * @param expectedType
70
+ * the expected type
71
+ * @param actualValue
72
+ * the violating value
66
73
*/
67
74
@ Deprecated
68
75
public ValidationException (final Class <?> expectedType , final Object actualValue ) {
@@ -71,6 +78,13 @@ public ValidationException(final Class<?> expectedType, final Object actualValue
71
78
72
79
/**
73
80
* Constructor.
81
+ *
82
+ * @param violatedSchema
83
+ * the schema instance which detected the schema violation
84
+ * @param expectedType
85
+ * the expected type
86
+ * @param actualValue
87
+ * the violating value
74
88
*/
75
89
public ValidationException (final Schema violatedSchema , final Class <?> expectedType ,
76
90
final Object actualValue ) {
@@ -87,12 +101,30 @@ private ValidationException(final Schema rootFailingSchema,
87
101
causingExceptions );
88
102
}
89
103
104
+ /**
105
+ * Constructor.
106
+ *
107
+ * @param violatedSchema
108
+ * the schema instance which detected the schema violation
109
+ * @param message
110
+ * the readable exception message
111
+ */
90
112
public ValidationException (final Schema violatedSchema , final String message ) {
91
113
this (violatedSchema , new StringBuilder ("#" ), message , Collections .emptyList ());
92
114
}
93
115
94
116
/***
95
117
* Constructor.
118
+ *
119
+ * @param violatedSchema
120
+ * the schema instance which detected the schema violation
121
+ * @param pointerToViolation
122
+ * a JSON pointer denoting the part of the document which violates the schema
123
+ * @param message
124
+ * the readable exception message
125
+ * @param causingExceptions
126
+ * a (possibly empty) list of validation failures. It is used if multiple schema
127
+ * violations are found by violatedSchema
96
128
*/
97
129
public ValidationException (final Schema violatedSchema , final StringBuilder pointerToViolation ,
98
130
final String message ,
@@ -125,6 +157,11 @@ public List<ValidationException> getCausingExceptions() {
125
157
return causingExceptions ;
126
158
}
127
159
160
+ @ Override
161
+ public String getMessage () {
162
+ return getPointerToViolation () + ": " + super .getMessage ();
163
+ }
164
+
128
165
public String getPointerToViolation () {
129
166
return pointerToViolation .toString ();
130
167
}
@@ -162,7 +199,7 @@ public ValidationException prepend(final String fragment, final Schema violatedS
162
199
List <ValidationException > prependedCausingExceptions = causingExceptions .stream ()
163
200
.map (exc -> exc .prepend (fragment ))
164
201
.collect (Collectors .toList ());
165
- return new ValidationException (newPointer , violatedSchema , getMessage (),
202
+ return new ValidationException (newPointer , violatedSchema , super . getMessage (),
166
203
prependedCausingExceptions );
167
204
}
168
205
0 commit comments