mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 09:59:49 -05:00
Improve the error message
This commit is contained in:
1 parent
26c9cf74cf
commit
d6d8cd1063
2 files changed
+21
-7
No files matched your search
@@ -73,6 +73,10 @@ public class TextManager {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if(e.getMessage().contains("Did not get expected response code, got 403 for")) {
|
||||
plugin.getLogger().log(Level.WARNING, "The language " + availableLanguage+" didn't configure correctly, please report to QuickShop.", e);
|
||||
continue;
|
||||
}
|
||||
plugin.getLogger().log(Level.WARNING, "Couldn't update the translation for locale " + availableLanguage, e);
|
||||
}
|
||||
}
|
||||
|
||||
+17
-7
@@ -23,6 +23,7 @@ import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CrowdinOTA implements Distribution {
|
||||
protected static final String CROWDIN_OTA_HOST = "https://distributions.crowdin.net/daf1a8db40f132ce157c457xrm4/";
|
||||
@@ -37,7 +38,7 @@ public class CrowdinOTA implements Distribution {
|
||||
Util.getCacheFolder().mkdirs();
|
||||
}
|
||||
|
||||
private byte[] requestWithCache(@NotNull String url, @Nullable File saveTo) {
|
||||
private byte[] requestWithCache(@NotNull String url, @Nullable File saveTo) throws IOException {
|
||||
byte[] data = requestCachePool.getIfPresent(url);
|
||||
if (data == null) {
|
||||
try {
|
||||
@@ -48,9 +49,6 @@ public class CrowdinOTA implements Distribution {
|
||||
if (saveTo != null)
|
||||
response.saveContent(saveTo);
|
||||
return response.asBytes();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -62,7 +60,13 @@ public class CrowdinOTA implements Distribution {
|
||||
@Nullable
|
||||
public Manifest getManifest() {
|
||||
String url = CROWDIN_OTA_HOST + "manifest.json";
|
||||
String data = new String(requestWithCache(url,null), StandardCharsets.UTF_8);
|
||||
String data = null;
|
||||
try {
|
||||
data = new String(requestWithCache(url,null), StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().log(Level.WARNING,"Failed to download manifest.json, multi-language system won't work");
|
||||
return null;
|
||||
}
|
||||
if (StringUtils.isEmpty(data))
|
||||
return null;
|
||||
return JsonUtil.getGson().fromJson(data, Manifest.class);
|
||||
@@ -71,7 +75,13 @@ public class CrowdinOTA implements Distribution {
|
||||
@Nullable
|
||||
public String getManifestJson() {
|
||||
String url = CROWDIN_OTA_HOST + "manifest.json";
|
||||
String data = new String(requestWithCache(url,null), StandardCharsets.UTF_8);
|
||||
String data;
|
||||
try {
|
||||
data = new String(requestWithCache(url,null), StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().log(Level.WARNING,"Failed to download manifest.json, multi-language system won't work");
|
||||
return null;
|
||||
}
|
||||
if (StringUtils.isEmpty(data))
|
||||
return null;
|
||||
return data;
|
||||
@@ -143,7 +153,7 @@ public class CrowdinOTA implements Distribution {
|
||||
String url = CROWDIN_OTA_HOST + "content" + fileCrowdinPath.replace("%locale%", crowdinLocale);
|
||||
byte[] bin = requestWithCache(url,cachedDataFile);
|
||||
if (bin == null)
|
||||
throw new IOException("Couldn't download translation from remote server. If you see any error like \"404 Not Found\", please report it to QuickShop.");
|
||||
throw new IOException("Couldn't download translation from remote server.");
|
||||
// update cache index
|
||||
data = Util.readToString(cachedDataFile);
|
||||
cacheMetadata.set(pathHash + ".timestamp", manifest.getTimestamp());
|
||||
|
||||
Reference in new issue
Block a user