add invalid response error case
This commit is contained in:
parent
a4c4cd00ae
commit
b26932fbfe
|
|
@ -20,10 +20,13 @@
|
|||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import Alamofire
|
||||
|
||||
public enum RequestError: Error {
|
||||
|
||||
case noConnection // no connection to the server
|
||||
case network(error: Error)
|
||||
case invalidResponse(error: AFError)
|
||||
case mapping(error: Error, response: Any)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,14 @@ public extension Reactive where Base: DataRequest {
|
|||
case .notConnectedToInternet, .timedOut:
|
||||
throw RequestError.noConnection
|
||||
default:
|
||||
throw RequestError.network(error: $0)
|
||||
throw RequestError.network(error: urlError)
|
||||
}
|
||||
case let afError as AFError:
|
||||
switch afError {
|
||||
case .responseSerializationFailed, .responseValidationFailed:
|
||||
throw RequestError.invalidResponse(error: afError)
|
||||
default:
|
||||
throw RequestError.network(error: afError)
|
||||
}
|
||||
default:
|
||||
throw RequestError.network(error: $0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue