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