Skip to content

Handle new error codes from the media upload endpoint #14401

@maxme

Description

@maxme

Expected behavior

In case of an error during media upload, we should show the exact error to help the user take a decision.

The list of errors are defined here in Calypso. Most interesting are:

  • rest_upload_limited_space
  • rest_upload_file_too_big
  • rest_upload_user_quota_exceeded

Note that these error codes are actually stored in the message field. Here is an sample response we get from the https://public-api.wordpress.com/rest/v1.1/sites/{SITE_ID}/media/new/ API endpoint in case of an upload on a quota limited site:

{
	"error": "upload_error",
	"message": "rest_upload_user_quota_exceeded|You have used your space quota. Please delete files before uploading. Back"
}
  • On the network side: It would be a good idea to split the error message (something like .split("|")), make the error code directly accessible by the UI.
  • On the UI, we should handle that error and display the message correctly instead of showing a generic message. This must be done:
    • In the media library.
    • In the editor.

Actual behavior

We show a generic error in the editor and in the media library:

Media Library Editor
1-post-1-file-not-uploaded-media-library-wpios-15 1 0 3 failed-to-insert-media-please-tap-for-options

More details on paaHJt-17e-p2

WPAndroid related ticket: wordpress-mobile/WordPress-Android#12325

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions