Better GitHub error messages (#112)

This commit is contained in:
Imran Remtulla
2022-11-14 20:56:04 -05:00
parent c8ec67aef3
commit aa2a25fffe
3 changed files with 22 additions and 25 deletions

View File

@@ -167,14 +167,8 @@ class GitHub extends AppSource {
}
return APKDetails(version, targetRelease['apkUrls']);
} else {
if (res.headers['x-ratelimit-remaining'] == '0') {
throw RateLimitError(
(int.parse(res.headers['x-ratelimit-reset'] ?? '1800000000') /
60000000)
.round());
}
throw NoReleasesError();
rateLimitErrorCheck(res);
throw getObtainiumHttpError(res);
}
}
@@ -200,15 +194,17 @@ class GitHub extends AppSource {
}
return urlsWithDescriptions;
} else {
if (res.headers['x-ratelimit-remaining'] == '0') {
throw RateLimitError(
(int.parse(res.headers['x-ratelimit-reset'] ?? '1800000000') /
60000000)
.round());
}
throw ObtainiumError(
res.reasonPhrase ?? 'Error ${res.statusCode.toString()}',
unexpected: true);
rateLimitErrorCheck(res);
throw getObtainiumHttpError(res);
}
}
rateLimitErrorCheck(Response res) {
if (res.headers['x-ratelimit-remaining'] == '0') {
throw RateLimitError(
(int.parse(res.headers['x-ratelimit-reset'] ?? '1800000000') /
60000000)
.round());
}
}
}