Report foreground location errors

This commit is contained in:
Yegor Vialov 2020-05-06 16:19:42 +00:00
parent e7cce01ca9
commit 17ec73b176

View File

@ -108,6 +108,7 @@ class LocationManager {
} }
updateDeviceLocation() async { updateDeviceLocation() async {
try {
Logger.d("[Foreground location] Started"); Logger.d("[Foreground location] Started");
Geolocator geolocator = Geolocator(); Geolocator geolocator = Geolocator();
var battery = Battery(); var battery = Battery();
@ -133,16 +134,22 @@ class LocationManager {
} }
}; };
Logger.d("[Foreground location] Sending data home..."); Logger.d("[Foreground location] Sending data home...");
var response = await http.post( http.Response response = await http.post(
url, url,
headers: {"Content-Type": "application/json"}, headers: {"Content-Type": "application/json"},
body: json.encode(data) body: json.encode(data)
); );
if (response.statusCode >= 300) {
Logger.e('Foreground location update error: ${response.body}');
}
Logger.d("[Foreground location] Got HTTP ${response.statusCode}"); Logger.d("[Foreground location] Got HTTP ${response.statusCode}");
} else { } else {
Logger.d("[Foreground location] No location. Aborting."); Logger.d("[Foreground location] No location. Aborting.");
} }
} }
} catch (e, stack) {
Logger.e('Foreground location error: ${e.toSTring()}', stacktrace: stack);
}
} }
} }