Просмотр исходного кода

Added more description exception messages.

Winston Li 12 лет назад
Родитель
Сommit
3dea6036f8

+ 0 - 2
services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/WLDirectoryNodeSnapshot.java

@@ -26,7 +26,6 @@ public class WLDirectoryNodeSnapshot implements CandidateSnapshot {
         projectURL = "http://" + hostname + "/" + projectName;
         this.directoryNode = directoryNode;
         this.callback = callback;
-        System.out.println(getJsonRepresentation());
     }
 
     @Override
@@ -67,7 +66,6 @@ public class WLDirectoryNodeSnapshot implements CandidateSnapshot {
 
     @Override
     public void approveWithVersionID(int versionID) {
-        System.out.println("approve with version " + versionID);
         callback.approveSnapshot(versionID, this);
     }
 

+ 3 - 0
services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/WriteLatexAPI.java

@@ -45,12 +45,15 @@ public class WriteLatexAPI implements WriteLatexDataSource {
 
     @Override
     public List<WritableRepositoryContents> getWritableRepositories(String projectName) throws FailedConnectionException, InvalidProjectException {
+        System.out.println("Fetching project: " + projectName);
         return dataModel.updateProjectWithName(projectName);
     }
 
     @Override
     public void putDirectoryContentsToProjectWithName(String projectName, RawDirectoryContents directoryContents, String hostname) throws SnapshotPostException, IOException, FailedConnectionException {
+        System.out.println("Pushing project: " + projectName);
         CandidateSnapshot candidate = dataModel.createCandidateSnapshotFromProjectWithContents(projectName, directoryContents, hostname);
+        System.out.println(candidate.getJsonRepresentation());
         SnapshotPushRequest snapshotPushRequest = new SnapshotPushRequest(candidate);
         snapshotPushRequest.request();
         SnapshotPushRequestResult result = snapshotPushRequest.getResult();

+ 6 - 1
services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/api/request/push/exception/InvalidFilesException.java

@@ -11,6 +11,11 @@ import java.util.List;
  */
 public class InvalidFilesException extends SnapshotPostException {
 
+    private static final String[] DESCRIPTION_LINES = {
+            "You have invalid files in your WriteLatex project.",
+            "Check your extensions."
+    };
+
     public InvalidFilesException(JsonObject json) {
         super(json);
     }
@@ -22,7 +27,7 @@ public class InvalidFilesException extends SnapshotPostException {
 
     @Override
     public List<String> getDescriptionLines() {
-        return Arrays.asList("invalid files, change ext or something");
+        return Arrays.asList(DESCRIPTION_LINES);
     }
 
     @Override

+ 6 - 1
services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/api/request/push/exception/InvalidProjectException.java

@@ -10,6 +10,11 @@ import java.util.List;
  */
 public class InvalidProjectException extends SnapshotPostException {
 
+    private static final String[] DESCRIPTION_LINES = {
+            "Your WriteLatex project is too big.",
+            "Delete some files and try again.."
+    };
+
     public InvalidProjectException(JsonElement jsonElement) {
         super(jsonElement);
     }
@@ -21,7 +26,7 @@ public class InvalidProjectException extends SnapshotPostException {
 
     @Override
     public List<String> getDescriptionLines() {
-        return Arrays.asList("your project is too big");
+        return Arrays.asList(DESCRIPTION_LINES);
     }
 
     @Override

+ 7 - 2
services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/api/request/push/exception/UnexpectedErrorException.java

@@ -11,18 +11,23 @@ import java.util.List;
  */
 public class UnexpectedErrorException extends SnapshotPostException {
 
+    private static final String[] DESCRIPTION_LINES = {
+            "There was an internal error with the WriteLatex server.",
+            "Please contact WriteLatex."
+    };
+
     public UnexpectedErrorException(JsonObject json) {
         super(json);
     }
 
     @Override
     public String getMessage() {
-        return "unexpected error";
+        return "writelatex error";
     }
 
     @Override
     public List<String> getDescriptionLines() {
-        return Arrays.asList("writelatex error");
+        return Arrays.asList(DESCRIPTION_LINES);
     }
 
     @Override