Use json error values returned by server
Mastodon API documentation on errors: https://docs.joinmastodon.org/entities/error/
Pixelfed currently uses the default Laravel format to return errors (message
key instead of Mastodon's error
), but I sent a patch to dansup to harmonize this with Mastodon's way of doing things.
Once this is implemented on Pixelfed's end, we can use code similar to this in the initAdapter function:
val error: String = (it.error as? HttpException)?.response()?.errorBody()?.string()?.ifEmpty { null }?.let { s ->
Gson().fromJson(s, Error::class.java)?.error?.ifBlank { null }
} ?: it.error.localizedMessage.orEmpty()
showError(motionLayout = motionLayout, errorLayout = errorLayout, errorText = error)