I have a completion handler that gets called inside my closure. However, the completion handler only gets called when everything goes well. In the case of an error, the completion handler never gets called.
func product(with id: String, _ completion: @escaping (Product) -> ()) {
// Make a network request for the product
...
if (product) {
completion(product)
}
}
Is this a bad design? I recently got the comment that completion handlers need to be called even in case of errors, otherwise the caller will be waiting indefinitely. I've never heard that before and now I'm wondering if this applies to Swift.