Skip to content

Commit

Permalink
Merge pull request #22 from writeas/return-error-on-login-404
Browse files Browse the repository at this point in the history
Don't return early if we get a 404 on login attempt
  • Loading branch information
AngeloStavrow authored Oct 6, 2020
2 parents 52ea441 + a671f83 commit accd9c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Sources/WriteFreely/WFClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,11 @@ public class WFClient {
}
} else {
// We didn't get a 200 OK, so return a WFError
guard let error = self.translateWFError(fromServerResponse: data) else { return }
guard let error = self.translateWFError(fromServerResponse: data) else {
// We couldn't generate a WFError from the server response data, so return an unknown error.
completion(.failure(WFError.unknownError))
return
}
completion(.failure(error))
}
}
Expand Down Expand Up @@ -1088,7 +1092,8 @@ private extension WFClient {
print("⛔️ \(error.message)")
return WFError(rawValue: error.code)
} catch {
return nil
print("⛔️ An unknown error occurred.")
return WFError.unknownError
}
}
}
1 change: 1 addition & 0 deletions Sources/WriteFreely/WFError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public enum WFError: Int, Error {
case internalServerError = 500
case badGateway = 502
case serviceUnavailable = 503
case unknownError = -1
}

struct ErrorMessage: Codable {
Expand Down

0 comments on commit accd9c4

Please sign in to comment.