FrisbeeError.other
williamhjcho opened this issue · 2 comments
In NetworkGetter.get
do {
let url = try URLWithQueryBuilder.build(withUrl: url, query: query)
makeRequest(url: url, onComplete: onComplete)
} catch where type(of: error) == FrisbeeError.self {
let error = error as? FrisbeeError ?? .unknown
return onComplete(.fail(error))
} catch {
return onComplete(.fail(.other(localizedDescription: error.localizedDescription)))
}
Errors
are caught and converted to a FrisbeeError
It should allow the propagation of Error
instead of wrapping it into a FrisbeeError.other(String)
since it could potentially remove some important error properties
Just to clarify, do you think that best approach should is FrisbeeError.other(Error)
instead String
?
I'm more inclined to not have a .other
case altogether
It only wraps some unmapped Error
on Frisbee's
side, which could have an undesired extra mapping stage for whoever uses it
Although a favorable case would be that
"every error thrown by Frisbee
is a FrisbeeError
"
But Swift doesn't guarantee that in function throws
, so the caller would still be dealing with generic Errors
then have to convert them to FrisbeeError
anyway