Skip to content
Snippets Groups Projects
Commit 5b641920 authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Improve network error model

parent 8b8260f9
Branches
No related tags found
No related merge requests found
......@@ -109,7 +109,7 @@ open class DataManager: NSObject, URLSessionDelegate
}
guard let response: HTTPURLResponse = response as? HTTPURLResponse else {
throw ResponseError.networkError(url: r.url, error: .unknown())
throw ResponseError.typeError
}
do {
......
......@@ -21,7 +21,7 @@ public enum ResponseError: Error
case noInternet
case timeout
case serverNotFound
case unknown(error: Error? = nil)
case unknown(error: Error)
}
public enum HttpError: Error
......@@ -29,9 +29,11 @@ public enum ResponseError: Error
case badRequest
case notFound
case internalError
case raw(code: Int)
}
case requestError
case typeError
case authError(url: String, error: AuthError)
case httpError(url: String, error: HttpError)
case networkError(url: String, error: NetworkError)
......@@ -52,7 +54,7 @@ public enum ResponseError: Error
return ResponseError.httpError(url: url, error: .internalError)
default:
return ResponseError.networkError(url: url, error: .unknown())
return ResponseError.httpError(url: url, error: .raw(code: code))
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment