Skip to content

Commit

Permalink
Switch from guard to if/let
Browse files Browse the repository at this point in the history
  • Loading branch information
captainbarbosa committed Jul 4, 2018
1 parent 9fbb49a commit ddda4f5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions MapboxGeocoder/MBGeocoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,13 @@ open class Geocoder: NSObject {
do {
let result = try decoder.decode(GeocodeAPIResult.self, from: data)
// Check if geocoding query failed
guard result.message == nil else {
let apiError = Geocoder.descriptiveError(["message": result.message!], response: response, underlyingError: error as NSError?)
if let message = result.message {
let apiError = Geocoder.descriptiveError(["message": message], response: response, underlyingError: error as NSError?)
DispatchQueue.main.async {
errorHandler(apiError)
}
return

}
DispatchQueue.main.async {
completionHandler(data)
Expand Down

0 comments on commit ddda4f5

Please sign in to comment.