You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import Foundation
import Statham
public enum ApiError : Error {
case notFound
case networkingError(NSError)
case jsonDecodingError(Error)
}
extension ApiError: CustomStringConvertible {
public var description: String {
switch self {
case .notFound: return NSLocalizedString("Not Found", comment: "Api Error: resource not found")
case .networkingError(let error): return error.localizedDescription
case .jsonDecodingError(let error):
#if DEBUG
if let error = error as? JsonDecodeError {
print(error.fullDescription)
}
#endif
return NSLocalizedString("Server error", comment: "Api Error: Server error")
}
}
}
The problem comes when using .mapError(), where the compiler complains about "Argument passed to call that takes no arguments". Digging in the github, I can see that indeed there is this following method mapError() that does not take any arguments and that is a new addition since the 0.5.0 version.
I can see however the right method here, but it seems that extension is sort of overriding the right one? Or am I missing something important here?
The text was updated successfully, but these errors were encountered:
The swift compiler often shows the "wrong" type of error in case of a type error.
Looking at your code, I'm guessing you're using the responseJSONPromise from the Alamofire extension. That returns a Promise<SuccessResponse<Any>, ErrorResponse>, not a Promise<SuccessResponse<AnyObject>, ErrorResponse> as you're using here.
We are using Promissum in a legacy project that we are trying to upgrade to Swift 3, but I found some issues when doing so.
Say that I have something like:
Where
ApiError
is:The problem comes when using
.mapError()
, where the compiler complains about "Argument passed to call that takes no arguments". Digging in the github, I can see that indeed there is this following method mapError() that does not take any arguments and that is a new addition since the 0.5.0 version.I can see however the right method here, but it seems that extension is sort of overriding the right one? Or am I missing something important here?
The text was updated successfully, but these errors were encountered: