Skip to content

Commit 3b58610

Browse files
daniel-kane-ebDan Kane
andauthored
[Windows] Handle errors in request access (#1458)
* Added catch all for geolocator.RequestAccessAsync() - this can throw errors if the Geolocation Service is disabled in Windows. * updated version and changelog --------- Co-authored-by: Dan Kane <[email protected]>
1 parent ff0d225 commit 3b58610

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

geolocator_windows/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.3
2+
3+
* Fixes crash under Windows when RequestAcess is called while the Geolocation Service is disabled. (#1455)
4+
15
## 0.2.2
26

37
* Fixes crash under Windows when getCurrentPosition method is called. (#1240)

geolocator_windows/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: geolocator_windows
22
description: Geolocation Windows plugin for Flutter. This plugin provides the Windows implementation for the geolocator.
33
repository: https://github.com/baseflow/flutter-geolocators
44
issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen
5-
version: 0.2.2
5+
version: 0.2.3
66

77
environment:
88
sdk: ">=2.15.0 <4.0.0"

geolocator_windows/windows/geolocator_plugin.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,13 @@ winrt::fire_and_forget GeolocatorPlugin::RequestAccessAsync(std::unique_ptr<Meth
141141
result->Success(EncodableValue((int)LocationPermission::Denied));
142142
else if(access == GeolocationAccessStatus::Unspecified)
143143
result->Success(EncodableValue((int)LocationPermission::DeniedForever));
144-
} catch(const std::exception& ex) {
144+
}
145+
catch(const std::exception& ex) {
145146
result->Error(ErrorCodeToString(ErrorCode::PermissionDefinitionsNotFound), ex.what());
146147
}
148+
catch (...) {
149+
result->Error(ErrorCodeToString(ErrorCode::UnknownError), "RequestAccess failed. Check the Geolocation Service is running.");
150+
}
147151
}
148152

149153
void GeolocatorPlugin::OnCheckPermission(std::unique_ptr<MethodResult<>> result) {

0 commit comments

Comments
 (0)