Skip to content

Commit

Permalink
Allow invalid API responses from myTBA
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachOrr committed Mar 17, 2019
1 parent ff933c0 commit 67a8776
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion the-blue-alliance-ios/Frameworks/MyTBAKit/MyTBA.swift
Expand Up @@ -114,7 +114,10 @@ class MyTBA {
}
#endif

let response = try! MyTBA.jsonDecoder.decode(T.self, from: data)
guard let response = try? MyTBA.jsonDecoder.decode(T.self, from: data) else {
completion(nil, MyTBAError.error("Unexpected response from myTBA API"))
return
}
if let baseResponse = response as? MyTBABaseResponse {
completion(response, error ?? baseResponse.error)
} else {
Expand Down

0 comments on commit 67a8776

Please sign in to comment.