Skip to content

Commit

Permalink
add: better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
harljo committed Apr 10, 2024
1 parent 6a0b461 commit fc24d40
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/client/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class _FritterTwitterClient extends TwitterClient {
return fetch(uri, headers: headers).timeout(timeout ?? _defaultTimeout).then((response) {
if (response?.statusCode != null && response!.statusCode >= 200 && response.statusCode < 300) {
return response;
} else if (response?.statusCode != null && response!.statusCode == 429) {
return Future.error(jsonDecode(response.body)['errors'][0]['message'].toString().replaceAll('.', ''));
} else {
return Future.error(
HttpException(response?.reasonPhrase ?? response?.statusCode.toString() ?? "unknown error"));
Expand Down

0 comments on commit fc24d40

Please sign in to comment.