diff --git a/lib/app/modules/dexcom/controllers/dexcom_controller.dart b/lib/app/modules/dexcom/controllers/dexcom_controller.dart index b264034..208910c 100644 --- a/lib/app/modules/dexcom/controllers/dexcom_controller.dart +++ b/lib/app/modules/dexcom/controllers/dexcom_controller.dart @@ -152,7 +152,7 @@ class DexcomController extends BaseController { startTimer(); } - Future getEgvs() async { + Future getEgvs() async { SharedPreferences _prefs = await SharedPreferences.getInstance(); HttpProvider _httpProvider = HttpProvider(); DateTime now = DateTime.now(); @@ -172,6 +172,14 @@ class DexcomController extends BaseController { await refreshToken(); // Refresh the token continue; // Continue the loop to retry the API call with the new token } + if (response == '500') { + Get.rawSnackbar( + message: "internal server error", + backgroundColor: Colors.red, + snackPosition: SnackPosition.BOTTOM); + + return null; + } EstimatedGlucoseValue resultedData = EstimatedGlucoseValue.fromJson(response); diff --git a/lib/app/modules/insights/controllers/insights_controller.dart b/lib/app/modules/insights/controllers/insights_controller.dart index 941c3e8..a2ea3cc 100644 --- a/lib/app/modules/insights/controllers/insights_controller.dart +++ b/lib/app/modules/insights/controllers/insights_controller.dart @@ -144,6 +144,9 @@ class InsightsController extends BaseController { } hideLoading(); } + else{ + hideLoading(); + } } else{ hideLoading(); diff --git a/lib/app/network/http_provider.dart b/lib/app/network/http_provider.dart index 68b74c6..31870b5 100644 --- a/lib/app/network/http_provider.dart +++ b/lib/app/network/http_provider.dart @@ -6,6 +6,7 @@ import '../../flavors/build_config.dart'; const int statusCodeValue = 200; const int invalidAccessToken = 401; +const int internalServerError=500; class HttpProvider { static final String? baseUrl = BuildConfig.instance.config.dexComBaseUrl; @@ -51,7 +52,12 @@ class HttpProvider { } else if (response.statusCode == invalidAccessToken) { return '401'; - } else { + } + else if (response.statusCode==internalServerError){ + + return '500'; + } + else { throw Exception('Failed to retrieve glucose values.'); } }