gdarko / digital-license-manager

Extendable License Manager for WordPress and WooCommerce 🔑
https://wordpress.org/plugins/digital-license-manager/
GNU General Public License v3.0
23 stars 5 forks source link

Add code and status to error when license key is not found. #11

Closed pondermatic closed 1 year ago

pondermatic commented 1 year ago

Issue

When the /wp-json/dlm/v1/licenses/activate REST API endpoint can not find the license key, it returns a WP_Error object with the message as a code and without an HTTP status.

Steps to reproduce

  1. Use the dlm-wp-updater library to render an activation form.
  2. Enter a license key that does not exist in the server.

Expected response

"The license key 'imaginary-key' could not be found" is displayed as a WordPress error notice.

Actual response

"Unable to decode response. (2)" is displayed as a WordPress error notice.

Solution

This PR changes the WordPress error response to send a data_error code, the message as a message, and an HTTP status of 404 as extra data.