Removed print and gave more descriptive error.

This commit is contained in:
Winston Li 2014-12-04 20:38:12 +00:00
parent ce9351186c
commit 3d19cb95b9

View file

@ -1,9 +1,9 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@ -12,10 +12,6 @@ import java.util.List;
*/
public class InvalidFilesException extends SnapshotPostException {
private static final String[] DESCRIPTION_LINES = {
"You have invalid files in your WriteLatex project."
};
private List<String> descriptionLines;
public InvalidFilesException(JsonObject json) {
@ -35,13 +31,10 @@ public class InvalidFilesException extends SnapshotPostException {
@Override
public void fromJSON(JsonElement json) {
descriptionLines = new LinkedList<String>();
descriptionLines.addAll(Arrays.asList(DESCRIPTION_LINES));
try {
for (JsonElement error : json.getAsJsonObject().get("errors").getAsJsonArray()) {
descriptionLines.add(describeError(error.getAsJsonObject()));
}
} catch (Throwable t) {
t.printStackTrace();
JsonArray errors = json.getAsJsonObject().get("errors").getAsJsonArray();
descriptionLines.add("You have " + errors.size() + " invalid files in your WriteLatex project:");
for (JsonElement error : errors) {
descriptionLines.add(describeError(error.getAsJsonObject()));
}
}