diff --git a/src/appstore.js b/src/appstore.js index 6e4a87920..927a138f9 100644 --- a/src/appstore.js +++ b/src/appstore.js @@ -127,7 +127,7 @@ async function getSubscription() { if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message); if (response.status === 401) throw new BoxError(BoxError.INVALID_CREDENTIALS); - if (response.status === 422) throw new BoxError(BoxError.LICENSE_ERROR); + if (response.status === 402) throw new BoxError(BoxError.LICENSE_ERROR); if (response.status === 502) throw new BoxError(BoxError.EXTERNAL_ERROR, `Stripe error: ${error.message}`); if (response.status !== 200) throw new BoxError(BoxError.EXTERNAL_ERROR, `Unknown error: ${error.message}`); @@ -161,7 +161,6 @@ async function purchaseApp(data) { if (response.status === 404) throw new BoxError(BoxError.NOT_FOUND); // appstoreId does not exist if (response.status === 401) throw new BoxError(BoxError.INVALID_CREDENTIALS); if (response.status === 402) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); - if (response.status === 422) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); // 200 if already purchased, 201 is newly purchased if (response.status !== 201 && response.status !== 200) throw new BoxError(BoxError.EXTERNAL_ERROR, util.format('App purchase failed. %s %j', response.status, response.body)); } @@ -184,7 +183,7 @@ async function unpurchaseApp(appId, data) { if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message); if (response.status === 404) return; // was never purchased if (response.status === 401) throw new BoxError(BoxError.INVALID_CREDENTIALS); - if (response.status === 422) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); + if (response.status === 402) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); if (response.status !== 201 && response.status !== 200) throw new BoxError(BoxError.EXTERNAL_ERROR, util.format('App unpurchase failed. %s %j', response.status, response.body)); [error, response] = await safe(superagent.del(url) @@ -217,7 +216,7 @@ async function getBoxUpdate(options) { if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message); if (response.status === 401) throw new BoxError(BoxError.INVALID_CREDENTIALS); - if (response.status === 422) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); + if (response.status === 402) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); if (response.status === 204) return; // no update if (response.status !== 200 || !response.body) throw new BoxError(BoxError.EXTERNAL_ERROR, util.format('Bad response: %s %s', response.status, response.text)); @@ -260,7 +259,7 @@ async function getAppUpdate(app, options) { if (error) throw new BoxError(BoxError.NETWORK_ERROR, error); if (response.status === 401) throw new BoxError(BoxError.INVALID_CREDENTIALS); - if (response.status === 422) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); + if (response.status === 402) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); if (response.status === 204) return; // no update if (response.status !== 200 || !response.body) throw new BoxError(BoxError.EXTERNAL_ERROR, util.format('Bad response: %s %s', response.status, response.text)); @@ -323,7 +322,7 @@ async function updateCloudron(data) { if (error) throw new BoxError(BoxError.NETWORK_ERROR, error); if (response.status === 401) throw new BoxError(BoxError.INVALID_CREDENTIALS); - if (response.status === 422) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); + if (response.status === 402) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); if (response.status !== 200) throw new BoxError(BoxError.EXTERNAL_ERROR, util.format('Bad response: %s %s', response.status, response.text)); debug(`updateCloudron: Cloudron updated with data ${JSON.stringify(data)}`); @@ -391,7 +390,7 @@ async function createTicket(info, auditSource) { const [error, response] = await safe(request); if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message); if (response.status === 401) throw new BoxError(BoxError.INVALID_CREDENTIALS); - if (response.status === 422) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); + if (response.status === 402) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); if (response.status !== 201) throw new BoxError(BoxError.EXTERNAL_ERROR, util.format('Bad response: %s %s', response.status, response.text)); await eventlog.add(eventlog.ACTION_SUPPORT_TICKET, auditSource, info); @@ -412,7 +411,7 @@ async function getApps() { if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message); if (response.status === 403 || response.status === 401) throw new BoxError(BoxError.INVALID_CREDENTIALS); - if (response.status === 422) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); + if (response.status === 402) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); if (response.status !== 200) throw new BoxError(BoxError.EXTERNAL_ERROR, util.format('App listing failed. %s %j', response.status, response.body)); if (!response.body.apps) throw new BoxError(BoxError.EXTERNAL_ERROR, util.format('Bad response: %s %s', response.status, response.text)); @@ -443,7 +442,7 @@ async function getAppVersion(appId, version) { if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message); if (response.status === 403 || response.statusCode === 401) throw new BoxError(BoxError.INVALID_CREDENTIALS); if (response.status === 404) throw new BoxError(BoxError.NOT_FOUND); - if (response.status === 422) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); + if (response.status === 402) throw new BoxError(BoxError.LICENSE_ERROR, response.body.message); if (response.status !== 200) throw new BoxError(BoxError.EXTERNAL_ERROR, util.format('App fetch failed. %s %j', response.status, response.body)); return response.body; diff --git a/src/boxerror.js b/src/boxerror.js index a7721fdeb..c0586ee54 100644 --- a/src/boxerror.js +++ b/src/boxerror.js @@ -52,7 +52,7 @@ BoxError.INACTIVE = 'Inactive'; // service/volume/mount BoxError.INTERNAL_ERROR = 'Internal Error'; BoxError.INVALID_CREDENTIALS = 'Invalid Credentials'; BoxError.IPTABLES_ERROR = 'IPTables Error'; -BoxError.LICENSE_ERROR = 'License Error'; +BoxError.LICENSE_ERROR = 'License Error'; // billing or subscription expired BoxError.LOGROTATE_ERROR = 'Logrotate Error'; BoxError.MAIL_ERROR = 'Mail Error'; BoxError.MOUNT_ERROR = 'Mount Error';