Skip to content

Commit

Permalink
chore: handle offline mode more graceful (#698)
Browse files Browse the repository at this point in the history
Co-authored-by: jdrueckert <jd.rueckert@googlemail.com>
  • Loading branch information
skaldarnar and jdrueckert committed Jun 30, 2023
1 parent 0fc550b commit f3c9f4a
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GitHub;
import org.kohsuke.github.GitHubBuilder;
import org.kohsuke.github.HttpException;
import org.kohsuke.github.extras.okhttp3.OkHttpConnector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -40,7 +41,14 @@ public GithubRepositoryAdapter(final OkHttpClient httpClient) {
.withConnector(new OkHttpConnector(httpClient))
.build();
logger.debug("Github rate limit: {}", github.getRateLimit());
} catch (HttpException e) {
if (e.getResponseCode() == -1) { // NOPMD

Check warning on line 45 in src/main/java/org/terasology/launcher/repositories/GithubRepositoryAdapter.java

View check run for this annotation

Check Run Reporter / code-analysis

com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck

com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck: Must have at least one statement.
// no internet connection, do nothing
} else {
e.printStackTrace();
}
} catch (IOException e) {

e.printStackTrace();
}
}
Expand Down Expand Up @@ -83,6 +91,12 @@ public List<GameRelease> fetchReleases() {
.collect(Collectors.toList());
logger.debug("Github rate limit: {}", github.getRateLimit());
return releases;
} catch (HttpException e) {
if (e.getResponseCode() == -1) { // NOPMD

Check warning on line 95 in src/main/java/org/terasology/launcher/repositories/GithubRepositoryAdapter.java

View check run for this annotation

Check Run Reporter / code-analysis

com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck

com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck: Must have at least one statement.
// no internet connection, do nothing
} else {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
Expand Down

0 comments on commit f3c9f4a

Please sign in to comment.