Skip to content

Commit

Permalink
fix: return error
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Aug 8, 2023
1 parent e693a03 commit 691dfad
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions ios/Plugin/NativeGeocoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,29 @@ struct NativeGeocoderOptions: Decodable {
options.maxResults = call.getInt("maxResults") ?? 1

forwardGeocodeHandler(address, options: options, completionHandler: { (resultObj, error) in
if let error = error {
call.reject(error.message)
} else {
if let error = error as? CLError {
var msg = "CLGeocoder:forwardGeocodeLocation Error"
switch error.code {
case .locationUnknown:
msg = "locationUnknown: location manager was unable to obtain a location value right now."
case .denied:
msg = "denied: user denied access to the location service."
case .promptDeclined:
msg = "promptDeclined: user didn’t grant the requested temporary authorization."
case .network:
msg = "network: network was unavailable or a network error occurred."
case .headingFailure:
msg = "headingFailure: heading could not be determined."
case .rangingUnavailable:
msg = "rangingUnavailable: ranging is disabled."
case .rangingFailure:
msg = "rangingFailure: a general ranging error occurred."
default : break
}
print(msg)
call.reject(msg)
}
else {
call.resolve(["addresses": resultObj])
}
})
Expand Down

0 comments on commit 691dfad

Please sign in to comment.