-
Notifications
You must be signed in to change notification settings - Fork 16
Avoid casting to NSError
in favor of WordPressApiError
#779
base: trunk
Are you sure you want to change the base?
Conversation
See discussion at #777 (comment) with @crazytonyli
let jetpackError = JetpackInstallError( | ||
title: endpointError.localizedDescription, | ||
code: endpointError.errorCode, | ||
key: endpointError.errorUserInfo[WordPressComRestApi.ErrorKeyErrorCode] as? String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can do endpointError.apiErrorCode
instead of using errorUserInfo
.
|
||
let status = RewindStatus(state: .unavailable) | ||
success(status) | ||
failure(endpointError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code returns error
. But there it's changed to endpointError
. I don't think we should change it here?
guard error.castedToEndpointErrorWitCode(.preconditionFailure) != nil else { | ||
success(RewindStatus(state: .unavailable)) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My brain can't process these two guard statements. But, are their logic changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed an unit test failed, I think this guard change here might be the cause?
See discussion at
#777 (comment) with @crazytonyli
Testing Details
See green CI.
CHANGELOG.md
if necessary. — N.A.