-
Couldn't load subscription status.
- Fork 3
Description
We have been able to convert all error types to WpApiError for WordPress REST API endpoints. However, if a site returns a custom error, we can't parse it and will return it as WpApiError::Unknown. The client can further parse the response using the WpApiError::Unknown::response field, but we can add some helpers to parse them to some known types.
We also probably don't need both WpApiError::ResponseParsingError & WpApiError::UnknownError, what do you think @crazytonyli?
One alternative we could consider is to allow each endpoint to return its own error type. I think this would work very well if this was a standalone Rust project, because we could use generics and trait bounds to still have some central handling. However, it may prove difficult for a uniffi project, because we are not allowed to use generics in the bindings and we can't return a trait bound object if I remember correctly.
Another alternative would be to add some WordPress.com specific error types, but that won't be a generic solution that'd allow working with custom plugins in the future.