Skip to content
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

Refactor WordPressComRestApiError #696

Merged
merged 13 commits into from
Jan 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Check error domain and code, instead of casting to WordPressComRestAp…
…iError

This is an unfortunate comprosie we need to make during a refactor(*).
After the refactor is done, the `error` variable here should be of type
`WordPressAPIError<WordPressComRestApiEndpointError>`. That means,
at the end, we can access the 'error code' in a more strongly-typed way.

(*): A WordPressComRestApi refactor to make it return
`WordPressAPIError` in its Swift API, instead of `NSError`.
crazytonyli committed Jan 18, 2024
commit accaa3e1f422b6cc67c6a5d304edc039ece20deb
2 changes: 1 addition & 1 deletion WordPressKit/ActivityServiceRemote.swift
Original file line number Diff line number Diff line change
@@ -154,7 +154,7 @@ open class ActivityServiceRemote: ServiceRemoteWordPressComREST {
}, failure: { error, _ in
// FIXME: A hack to support free WPCom sites and Rewind. Should be obsolote as soon as the backend
// stops returning 412's for those sites.
if let error = error as? WordPressComRestApiError, error == WordPressComRestApiError.preconditionFailure {
if error.domain == WordPressComRestApiEndpointError.errorDomain, error.code == WordPressComRestApiError.preconditionFailure.rawValue {
let status = RewindStatus(state: .unavailable)
success(status)
return