Skip to content

Commit

Permalink
ads: improve error handling and logs (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
sstasi95 committed Feb 12, 2025
1 parent 5a471b2 commit 8127aa5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/src/services/ads_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,20 @@ class AdsServiceImpl with AppLogger implements AdsService {
}

bool _isNetworkError(String errorMessage) =>
['Network error', 'Error while connecting to ad server'].any(errorMessage.contains);
['network error', 'error while connecting to ad server'].any(errorMessage.toLowerCase().contains);

bool _isTooManyFailedRequests(String errorMessage) => errorMessage.contains('Too many recently failed requests');
bool _isTooManyFailedRequests(String errorMessage) =>
errorMessage.toLowerCase().contains('too many recently failed requests');

bool _isJavascriptEngineNotFound(String errorMessage) => errorMessage.contains('Unable to obtain a JavascriptEngine');
bool _isJavascriptEngineNotFound(String errorMessage) =>
errorMessage.toLowerCase().contains('unable to obtain a javascriptengine');

/// Stops requesting ads for 30 seconds.
void _pauseRequestingAds() {
logDebug('Pausing requesting ads');
_showAds = false;

Timer(Duration(seconds: 30), () {
Timer(const Duration(seconds: 30), () {
_showAds = true;
logDebug('Ads can be requested again');
});
Expand Down

0 comments on commit 8127aa5

Please sign in to comment.