1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-19 03:33:42 +01:00

fix(gitlab): error catch

This commit is contained in:
Rongjian Zhang 2020-01-30 12:53:07 +08:00
parent 9121316acd
commit f3e5988413

View File

@ -151,7 +151,7 @@ class AuthModel with ChangeNotifier {
final res = await http.get('${activeAccount.domain}/api/v4$p', final res = await http.get('${activeAccount.domain}/api/v4$p',
headers: {'Private-Token': token}); headers: {'Private-Token': token});
final info = json.decode(utf8.decode(res.bodyBytes)); final info = json.decode(utf8.decode(res.bodyBytes));
if (info['message'] != null) throw info['message']; if (info is Map && info['message'] != null) throw info['message'];
return info; return info;
} }
@ -161,7 +161,7 @@ class AuthModel with ChangeNotifier {
final next = int.tryParse( final next = int.tryParse(
res.headers['X-Next-Pages'] ?? res.headers['x-next-page'] ?? ''); res.headers['X-Next-Pages'] ?? res.headers['x-next-page'] ?? '');
final info = json.decode(utf8.decode(res.bodyBytes)); final info = json.decode(utf8.decode(res.bodyBytes));
if (info['message'] != null) throw info['message']; if (info is Map && info['message'] != null) throw info['message'];
return DataWithPage(info, next, next != null); return DataWithPage(info, next, next != null);
} }