mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-23 09:29:41 +02:00
Better GitHub error messages (#112)
This commit is contained in:
@@ -167,14 +167,8 @@ class GitHub extends AppSource {
|
|||||||
}
|
}
|
||||||
return APKDetails(version, targetRelease['apkUrls']);
|
return APKDetails(version, targetRelease['apkUrls']);
|
||||||
} else {
|
} else {
|
||||||
if (res.headers['x-ratelimit-remaining'] == '0') {
|
rateLimitErrorCheck(res);
|
||||||
throw RateLimitError(
|
throw getObtainiumHttpError(res);
|
||||||
(int.parse(res.headers['x-ratelimit-reset'] ?? '1800000000') /
|
|
||||||
60000000)
|
|
||||||
.round());
|
|
||||||
}
|
|
||||||
|
|
||||||
throw NoReleasesError();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,15 +194,17 @@ class GitHub extends AppSource {
|
|||||||
}
|
}
|
||||||
return urlsWithDescriptions;
|
return urlsWithDescriptions;
|
||||||
} else {
|
} else {
|
||||||
if (res.headers['x-ratelimit-remaining'] == '0') {
|
rateLimitErrorCheck(res);
|
||||||
throw RateLimitError(
|
throw getObtainiumHttpError(res);
|
||||||
(int.parse(res.headers['x-ratelimit-reset'] ?? '1800000000') /
|
}
|
||||||
60000000)
|
}
|
||||||
.round());
|
|
||||||
}
|
rateLimitErrorCheck(Response res) {
|
||||||
throw ObtainiumError(
|
if (res.headers['x-ratelimit-remaining'] == '0') {
|
||||||
res.reasonPhrase ?? 'Error ${res.statusCode.toString()}',
|
throw RateLimitError(
|
||||||
unexpected: true);
|
(int.parse(res.headers['x-ratelimit-reset'] ?? '1800000000') /
|
||||||
|
60000000)
|
||||||
|
.round());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,14 +27,9 @@ class GitHubStars implements MassAppUrlSource {
|
|||||||
}
|
}
|
||||||
return urlsWithDescriptions;
|
return urlsWithDescriptions;
|
||||||
} else {
|
} else {
|
||||||
if (res.headers['x-ratelimit-remaining'] == '0') {
|
var gh = GitHub();
|
||||||
throw RateLimitError(
|
gh.rateLimitErrorCheck(res);
|
||||||
(int.parse(res.headers['x-ratelimit-reset'] ?? '1800000000') /
|
throw getObtainiumHttpError(res);
|
||||||
60000000)
|
|
||||||
.round());
|
|
||||||
}
|
|
||||||
|
|
||||||
throw ObtainiumError('Unable to find user\'s starred repos');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:html/dom.dart';
|
import 'package:html/dom.dart';
|
||||||
|
import 'package:http/http.dart';
|
||||||
import 'package:obtainium/app_sources/fdroid.dart';
|
import 'package:obtainium/app_sources/fdroid.dart';
|
||||||
import 'package:obtainium/app_sources/github.dart';
|
import 'package:obtainium/app_sources/github.dart';
|
||||||
import 'package:obtainium/app_sources/gitlab.dart';
|
import 'package:obtainium/app_sources/gitlab.dart';
|
||||||
@@ -164,6 +165,11 @@ class AppSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObtainiumError getObtainiumHttpError(Response res) {
|
||||||
|
return ObtainiumError(
|
||||||
|
res.reasonPhrase ?? 'Error ${res.statusCode.toString()}');
|
||||||
|
}
|
||||||
|
|
||||||
abstract class MassAppUrlSource {
|
abstract class MassAppUrlSource {
|
||||||
late String name;
|
late String name;
|
||||||
late List<String> requiredArgs;
|
late List<String> requiredArgs;
|
||||||
|
Reference in New Issue
Block a user