mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-15 05:11:57 +00:00
Display a more specific message for v2 projects
This commit is contained in:
parent
3a374e0ba7
commit
44d3ddd9aa
2 changed files with 25 additions and 5 deletions
|
@ -8,6 +8,16 @@ import java.util.List;
|
|||
|
||||
public class MissingRepositoryException extends SnapshotAPIException {
|
||||
|
||||
public static final String GENERIC_REASON =
|
||||
"This Overleaf project currently has no git access.\n" +
|
||||
"\n" +
|
||||
"If you think this is an error, contact support at support@overleaf.com.";
|
||||
|
||||
public static final String EXPORTED_TO_V2 =
|
||||
"This Overleaf project has been moved to Overleaf v2, and git access is temporarily unsupported.\n" +
|
||||
"\n" +
|
||||
"See https://www.overleaf.com/help/342 for more information.";
|
||||
|
||||
private String message = "";
|
||||
|
||||
public MissingRepositoryException() {
|
||||
|
|
|
@ -2,6 +2,7 @@ package uk.ac.ic.wlgitbridge.snapshot.base;
|
|||
|
||||
import com.google.api.client.http.*;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ning.http.client.AsyncHttpClient;
|
||||
import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
|
||||
import uk.ac.ic.wlgitbridge.util.Instance;
|
||||
|
@ -74,13 +75,22 @@ public abstract class Request<T extends Result> {
|
|||
if (sc == HttpServletResponse.SC_UNAUTHORIZED || sc == HttpServletResponse.SC_FORBIDDEN) {
|
||||
throw new ForbiddenException();
|
||||
} else if (sc == HttpServletResponse.SC_NOT_FOUND) {
|
||||
try {
|
||||
JsonObject json = Instance.gson.fromJson(httpCause.getContent(), JsonObject.class);
|
||||
String message = json.get("message").getAsString();
|
||||
|
||||
if ("Exported to v2".equals(message)) {
|
||||
throw new MissingRepositoryException(MissingRepositoryException.EXPORTED_TO_V2);
|
||||
}
|
||||
} catch (IllegalStateException
|
||||
| ClassCastException
|
||||
| NullPointerException _) {
|
||||
// disregard any errors that arose while handling the JSON
|
||||
}
|
||||
|
||||
throw new MissingRepositoryException();
|
||||
} else if (sc >= 400 && sc < 500) {
|
||||
throw new MissingRepositoryException(
|
||||
"This project is currently inaccessible over Git.\n" +
|
||||
"\n" +
|
||||
"If you think this is an error, contact support at support@overleaf.com."
|
||||
);
|
||||
throw new MissingRepositoryException(MissingRepositoryException.GENERIC_REASON);
|
||||
}
|
||||
throw new FailedConnectionException(cause);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue