-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Hello I have a question about casting from error to Moya error? #2329
Comments
What’s your specific question? Do you have a code snippet that illustrates your issue? |
@Gerzer Hello! as you see i tried to convert error to MoyaError but it doesn't work guard let errorCode = (error as? MoyaError)?.response?.statusCode else {
// error as? MoyaError is nil
if let moyaError = (error as? MoyaError), moyaError.errorCode == 6 {
return Single.error(api.errorMap[1009] ?? error)
}
return Single.error(error)
} |
Swift doesn’t (yet) have typed errors, so the compiler can’t guarantee that all errors that a Moya function might throw will indeed be |
@Gerzer Hmm.. Then How Can i use statusCode on error ?? |
You can only get the Example usage: do {
// Make a request…
} catch let moyaError as MoyaError {
let statusCode = moyaError.respone?.statusCode
// Do something with the status code…
} catch {
// It’s not a Moya error, so there’s no statusCode property
} |
No description provided.
The text was updated successfully, but these errors were encountered: