Make map closure throwable?
aryaxt opened this issue · 3 comments
aryaxt commented
I think it would be great to make map
throwable, and in case of throwing trigger onFailure. The usage could be
protocol Deserializable {
init(json: [AnyHashable: Any]) throws
}
func fetch<T: Deserializable>(type: T.Type, path: String) -> Future<T, NEtworkError> {
return restClient.fetch(path: path).map {
return try type(json: $0)
}
}
yonaskolb commented
I think rethrows
would be better so every usage site wouldn't have to add try
if they don't have a throwing map closure
arnopoulos commented
I like the addition of rethrows that way it won't be a breaking API change either
aryaxt commented
I think my problem might have been something else, looking at the source it looks like it already throws