BottleRocketStudios / iOS-Hyperspace

An extremely lightweight wrapper around URLSession to make working with APIs a breeze.
Apache License 2.0
47 stars 17 forks source link

WIP - Improve error details when the underlying request fails #105

Closed tylermilner closed 4 years ago

tylermilner commented 5 years ago

Added an associated type to the unknownError case of NetworkServiceError. Previously, the Error provided in the completion of the execution of a request was being thrown away if the response parameter was not a HTTPURLResponse. In some cases, these errors were internally mapped to a NetworkServiceError (noInternetConnection, timedOut, and cancelled), but now clients have access to all other errors that might occur (NSURLErrorBadURL, NSURLErrorCannotFindHost, NSURLErrorDNSLookupFailed, etc.).

Basically, instead of needing to manually map a lot more cases in this switch, we now pass the underlying error through so that clients can have a more descriptive explanation of what went wrong vs just getting back a NetworkServiceError.unknownError.

tylermilner commented 4 years ago

I think #130 and version 4.0 in general should address a lot of these ideas. Closing...