Skip to content

Commit b1e9cb7

Browse files
committed
display a different error when the json isn't valid
1 parent 27b384b commit b1e9cb7

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

src/main/java/fr/minecraftforgefrance/common/RemoteInfoReader.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
package fr.minecraftforgefrance.common;
22

3+
import static fr.minecraftforgefrance.common.Localization.LANG;
4+
5+
import java.io.IOException;
36
import java.io.InputStream;
47
import java.io.InputStreamReader;
58
import java.net.URI;
9+
import java.net.URISyntaxException;
610
import java.net.URLConnection;
711
import java.util.ArrayList;
812

13+
import javax.swing.JOptionPane;
14+
915
import com.google.common.base.Charsets;
1016
import com.google.common.base.Splitter;
1117
import com.google.common.collect.Lists;
1218

1319
import argo.jdom.JdomParser;
1420
import argo.jdom.JsonNode;
1521
import argo.jdom.JsonRootNode;
22+
import argo.saj.InvalidSyntaxException;
1623

1724
public class RemoteInfoReader
1825
{
@@ -28,7 +35,6 @@ public RemoteInfoReader(String url)
2835

2936
public boolean init()
3037
{
31-
3238
try
3339
{
3440
URI uri = new URI(this.remoteUrl);
@@ -37,8 +43,21 @@ public boolean init()
3743
this.data = this.parser.parse(new InputStreamReader(in, Charsets.UTF_8));
3844
return true;
3945
}
40-
catch(Exception e)
46+
catch(InvalidSyntaxException e)
47+
{
48+
JOptionPane.showMessageDialog(null, LANG.getTranslation("err.jsoninvalid"), LANG.getTranslation("misc.error"), JOptionPane.ERROR_MESSAGE);
49+
e.printStackTrace();
50+
return false;
51+
}
52+
catch(IOException e)
53+
{
54+
JOptionPane.showMessageDialog(null, LANG.getTranslation("err.cannotreadremote"), LANG.getTranslation("misc.error"), JOptionPane.ERROR_MESSAGE);
55+
e.printStackTrace();
56+
return false;
57+
}
58+
catch(URISyntaxException e)
4159
{
60+
JOptionPane.showMessageDialog(null, LANG.getTranslation("err.cannotreadremote"), LANG.getTranslation("misc.error"), JOptionPane.ERROR_MESSAGE);
4261
e.printStackTrace();
4362
return false;
4463
}

src/main/java/fr/minecraftforgefrance/installer/Installer.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package fr.minecraftforgefrance.installer;
22

3-
import static fr.minecraftforgefrance.common.Localization.LANG;
4-
5-
import javax.swing.JOptionPane;
63
import javax.swing.UIManager;
74

85
import fr.minecraftforgefrance.common.Localization;
@@ -26,7 +23,6 @@ public static void main(String[] args)
2623
RemoteInfoReader.instance = new RemoteInfoReader(LocalInfoReader.instance().getRemoteUrl());
2724
if(!RemoteInfoReader.instance().init())
2825
{
29-
JOptionPane.showMessageDialog(null, LANG.getTranslation("err.cannotreadremote"), LANG.getTranslation("misc.error"), JOptionPane.ERROR_MESSAGE);
3026
return;
3127
}
3228
frame = new InstallerFrame();

src/main/resources/langs/EN.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ err.cannotdownload=Could not download
3131
err.cannotwriteversion=There was a problem while writing the launcher version. Is it write protected?
3232
err.cannotwriteprofile=There was a problem while writing the launcher profile. Is it write protected?
3333
err.cannotreadremote=Could not read remote info, please check your Internet connection
34+
err.jsoninvalid=The file remote_profile.json isn't valid !
3435
err.cannotopenurl=An error occurred while opening URL : %s
3536
err.bigimage=The image is too big!
3637
err.cannotfindlocalinfo=Local information not found, file /installer/local_info.json is missing in the jar

src/main/resources/langs/FR.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ err.cannotdownload=Impossible de télécharger
3131
err.cannotwriteversion=Il y a eu un problème lors de l'écriture de la version du launcher. Les permissions en écriture sont-elles accordées?
3232
err.cannotwriteprofile=Il y a eu un problème lors de l'écriture du profil. Les permissions en écriture sont-elles accordées?
3333
err.cannotreadremote=Impossible d'obtenir les informations de l'hôte distant, veuillez vérifier votre connexion Internet
34+
err.jsoninvalid=Le fichier remote_profile.json est invalide !
3435
err.cannotopenurl=Problème lors de l'ouverture de l'URL : %s
3536
err.bigimage=L'image est trop grande
3637
err.cannotfindlocalinfo=Informations locales introuvables, le fichier /installer/local_info.json est manquant dans le .jar

0 commit comments

Comments
 (0)