@@ -69,18 +69,28 @@ public GitLabApiException(Response response) {
69
69
// If the node is an object, then it is validation errors
70
70
if (jsonMessage .isObject ()) {
71
71
72
+ StringBuilder buf = new StringBuilder ();
72
73
validationErrors = new HashMap <>();
73
74
Iterator <Entry <String , JsonNode >> fields = jsonMessage .fields ();
74
75
while (fields .hasNext ()) {
75
76
76
77
Entry <String , JsonNode > field = fields .next ();
78
+ String fieldName = field .getKey ();
77
79
List <String > values = new ArrayList <>();
78
- validationErrors .put (field . getKey () , values );
80
+ validationErrors .put (fieldName , values );
79
81
for (JsonNode value : field .getValue ()) {
80
82
values .add (value .asText ());
81
83
}
84
+
85
+ if (values .size () > 0 ) {
86
+ buf .append ((buf .length () > 0 ? ", " : "" )).append (fieldName );
87
+ }
82
88
}
83
89
90
+ if (buf .length () > 0 ) {
91
+ this .message = "The following fields have validation errors: " + buf .toString ();
92
+ }
93
+
84
94
} else {
85
95
this .message = jsonMessage .asText ();
86
96
}
@@ -131,7 +141,7 @@ public final String getReason() {
131
141
132
142
/**
133
143
* Returns the HTTP status code that was the cause of the exception. returns 0 if the
134
- * causing error was not an HTTP related exception.
144
+ * causing error was not an HTTP related exception
135
145
*
136
146
* @return the HTTP status code, returns 0 if the causing error was not an HTTP related exception
137
147
*/
0 commit comments