wp-error
Common logic to process WordPress.com API responses into JS Error objectsCreates a JavaScript
Error
instance, with properties copied over from
the given object, and HTTP response status interpreted.Installation
Installwp-error
using npm
:$ npm install --save wp-error
Examples
var err = new WPError({
error: 'processing_failed',
error_description: 'Invalid upload format',
);
err.toString();
// "ProcessingFailedError: Invalid upload format"