Automattic / Gravatar-SDK-Android

Gravatar Android library
https://gravatar.com
Mozilla Public License 2.0
44 stars 11 forks source link

Add 413 HTTP error - CONTENT_TOO_LARGE #402

Closed hamorillo closed 2 weeks ago

hamorillo commented 2 weeks ago

Closes #352

Description

This PR aims to solve the same issue as https://github.com/Automattic/Gravatar-SDK-iOS/pull/467 in the iOS repo.

When an image that is too big is uploaded, the server will answer with a 413, which we should handle and show the proper error message. For that reason, we need to add a new ErrorType.

Note: We've discussed ErrorType being a sealed class and the problems that could arise when adding a new ErrorType (Breaking change—it can break the compilation in a when clause). I'll open a different PR for that. #401

Testing Steps

As we are compressing and limiting the maximum size of the final image, it's not easy to test the changes. You have two options:

Modifying the code

Mock the server response

In both options -> Verify you see the error on the avatar picker with the associated message.

image
wpmobilebot commented 2 weeks ago
📲 You can test the changes from this Pull Request in Gravatar Demo by scanning the QR code below to install the corresponding build.
App Name Gravatar Demo
Commit1fa495556f79d38e6dbc6a2e7b927980ea5b3efc
Direct Downloadgravatar-demo-prototype-build-pr402-1fa4955.apk