Skip to content

Commit 70b1727

Browse files
simonseyer1ec5
authored andcommitted
Added nil check before adding underlying error to dict
Cherry-picked from 967218c.
1 parent 7ee2f61 commit 70b1727

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

MapboxGeocoder/MBGeocoder.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,9 @@ public class Geocoder: NSObject {
306306
userInfo[NSLocalizedFailureReasonErrorKey] = failureReason ?? userInfo[NSLocalizedFailureReasonErrorKey] ?? NSHTTPURLResponse.localizedStringForStatusCode(error?.code ?? -1)
307307
userInfo[NSLocalizedRecoverySuggestionErrorKey] = recoverySuggestion ?? userInfo[NSLocalizedRecoverySuggestionErrorKey]
308308
}
309-
userInfo[NSUnderlyingErrorKey] = error
309+
if let error = error {
310+
userInfo[NSUnderlyingErrorKey] = error
311+
}
310312
return NSError(domain: error?.domain ?? MBGeocoderErrorDomain, code: error?.code ?? -1, userInfo: userInfo)
311313
}
312314
}

0 commit comments

Comments
 (0)