WIP #49 Catch http errors inside location isolate
This commit is contained in:
parent
6663bcad72
commit
ab5bf3b807
@ -16,7 +16,6 @@ class LocationManager {
|
||||
Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.medium).then((location) {
|
||||
Logger.d("[Location isolate #${Isolate.current.hashCode}] Got location: ${location.latitude} ${location.longitude}. Sending home...");
|
||||
int battery = DateTime.now().hour;
|
||||
try {
|
||||
String url = "$httpWebHost/api/webhook/$webhookId";
|
||||
Map<String, String> headers = {};
|
||||
headers["Content-Type"] = "application/json";
|
||||
@ -32,10 +31,7 @@ class LocationManager {
|
||||
url,
|
||||
headers: headers,
|
||||
body: json.encode(data)
|
||||
);
|
||||
} catch (e) {
|
||||
print("[Location isolate #${Isolate.current.hashCode}] Error sending location: ${e.toString()}");
|
||||
}
|
||||
).catchError((e) => print("[Location isolate #${Isolate.current.hashCode}] Error sending data: ${e.toString()}"));
|
||||
});
|
||||
|
||||
} else {
|
||||
@ -141,7 +137,7 @@ class LocationManager {
|
||||
);
|
||||
Logger.d("[Location] ...done.");
|
||||
} else {
|
||||
print("[Location] No webhook id. Aborting");
|
||||
Logger.d("[Location] No webhook id. Aborting");
|
||||
}
|
||||
} else {
|
||||
Logger.d("[Location] Location tracking is disabled");
|
||||
|
Reference in New Issue
Block a user