Skip to content

Commit f3c9f4a

Browse files
chore: handle offline mode more graceful (#698)
Co-authored-by: jdrueckert <[email protected]>
1 parent 0fc550b commit f3c9f4a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/org/terasology/launcher/repositories/GithubRepositoryAdapter.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.kohsuke.github.GHRepository;
1212
import org.kohsuke.github.GitHub;
1313
import org.kohsuke.github.GitHubBuilder;
14+
import org.kohsuke.github.HttpException;
1415
import org.kohsuke.github.extras.okhttp3.OkHttpConnector;
1516
import org.slf4j.Logger;
1617
import org.slf4j.LoggerFactory;
@@ -40,7 +41,14 @@ public GithubRepositoryAdapter(final OkHttpClient httpClient) {
4041
.withConnector(new OkHttpConnector(httpClient))
4142
.build();
4243
logger.debug("Github rate limit: {}", github.getRateLimit());
44+
} catch (HttpException e) {
45+
if (e.getResponseCode() == -1) { // NOPMD
46+
// no internet connection, do nothing
47+
} else {
48+
e.printStackTrace();
49+
}
4350
} catch (IOException e) {
51+
4452
e.printStackTrace();
4553
}
4654
}
@@ -83,6 +91,12 @@ public List<GameRelease> fetchReleases() {
8391
.collect(Collectors.toList());
8492
logger.debug("Github rate limit: {}", github.getRateLimit());
8593
return releases;
94+
} catch (HttpException e) {
95+
if (e.getResponseCode() == -1) { // NOPMD
96+
// no internet connection, do nothing
97+
} else {
98+
e.printStackTrace();
99+
}
86100
} catch (IOException e) {
87101
e.printStackTrace();
88102
}

0 commit comments

Comments
 (0)