Author: Chris Lattner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
enum BetterDecodingError: CustomStringConvertible { | |
case dataCorrupted(_ message: String) | |
case keyNotFound(_ message: String) | |
case typeMismatch(_ message: String) | |
case valueNotFound(_ message: String) | |
case any(_ error: Error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol ApiRequest { | |
var urlRequest: URLRequest { get } | |
} | |
protocol ApiClient { | |
func execute<T>(request: ApiRequest, completionHandler: @escaping (_ result: Result<ApiResponse<T>>) -> Void) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct API { | |
typealias Result = () throws -> JSON | |
enum Error: ErrorType { | |
case ConnectionError(NSError?) | |
case ServerError(statusCode: Int, message: String?) | |
case JSONError(NSError?) | |
} | |
} |