Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FrisbeeError.other #2

Open
williamhjcho opened this issue Jan 5, 2018 · 2 comments
Open

FrisbeeError.other #2

williamhjcho opened this issue Jan 5, 2018 · 2 comments

Comments

@williamhjcho
Copy link
Collaborator

williamhjcho commented Jan 5, 2018

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

@ronanrodrigo
Copy link
Owner

Just to clarify, do you think that best approach should is FrisbeeError.other(Error) instead String?

@williamhjcho
Copy link
Collaborator Author

williamhjcho commented Jan 6, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants