@@ -52,17 +52,30 @@ class LocationPickerHelperFlavor @Inject constructor(
52
52
* https://developer.android.com/develop/sensors-and-location/location/retrieve-current#BestEstimate
53
53
*/
54
54
@SuppressLint(" MissingPermission" )
55
+ @Suppress(" TooGenericExceptionCaught" )
55
56
private suspend fun getLocationWithGms (onSuccess : (GeoLocatedAddress )-> Unit ,onError : ()-> Unit ) {
56
57
if (locationPickerHelper.isLocationServicesEnabled()) {
57
58
AppJsonStyledLogger .log(
58
59
level= KaliumLogLevel .INFO ,
59
60
leadingMessage= " GetLocation" ,
60
61
jsonStringKeyValues= mapOf (" isUsingGms" totrue )
61
62
)
62
- val locationProvider= LocationServices .getFusedLocationProviderClient(context)
63
- val currentLocation=
64
- locationProvider.getCurrentLocation(Priority .PRIORITY_HIGH_ACCURACY ,CancellationTokenSource ().token).await()
65
- onSuccess(geocoderHelper.getGeoLocatedAddress(currentLocation))
63
+ try {
64
+ val locationProvider= LocationServices .getFusedLocationProviderClient(context)
65
+ val currentLocation=
66
+ locationProvider.getCurrentLocation(Priority .PRIORITY_HIGH_ACCURACY ,CancellationTokenSource ().token).await()
67
+ onSuccess(geocoderHelper.getGeoLocatedAddress(currentLocation))
68
+ }catch (e: Exception ) {
69
+ AppJsonStyledLogger .log(
70
+ level= KaliumLogLevel .WARN ,
71
+ leadingMessage= " GetLocation" ,
72
+ jsonStringKeyValues= mapOf (
73
+ " isUsingGms" totrue ,
74
+ " error" to" Location services are not available"
75
+ )
76
+ )
77
+ onError()
78
+ }
66
79
}else {
67
80
AppJsonStyledLogger .log(
68
81
level= KaliumLogLevel .WARN ,