diff --git a/src/install.js b/src/install.js index dc3ade4e..a4d24228 100644 --- a/src/install.js +++ b/src/install.js @@ -223,7 +223,7 @@ Run ppm -v after installing Git to see what version has been detected.\ retries: 4 }; const response = await request.get(requestSettings).catch(error => { - let message = `Request for package information failed: ${error.message}`; + let message = `Request for package information failed: ${request.getErrorMessage(null, error)}`; if (error.status) { message += ` (${error.status})`; } throw message; }); diff --git a/src/star.js b/src/star.js index e5f7251b..6f4c29c0 100644 --- a/src/star.js +++ b/src/star.js @@ -44,7 +44,7 @@ Run \`ppm stars\` to see all your starred packages.\ } }; - const response = await request.post(requestSettings).catch(error => { this.logFailure(); throw error; }); + const response = await request.post(requestSettings).catch(error => { this.logFailure(); throw request.getErrorMessage(null, error); }); const body = response.body ?? {}; if ((response.statusCode === 404) && ignoreUnpublishedPackages) { process.stdout.write('skipped (not published)\n'.yellow); @@ -52,7 +52,7 @@ Run \`ppm stars\` to see all your starred packages.\ } if (response.statusCode !== 200) { this.logFailure(); - const message = request.getErrorMessage(body, error); + const message = request.getErrorMessage(body, null); throw `Starring package failed: ${message}`; } diff --git a/src/unpublish.js b/src/unpublish.js index 2b3210a5..64d66d57 100644 --- a/src/unpublish.js +++ b/src/unpublish.js @@ -49,18 +49,18 @@ name is specified.\ if (packageVersion) { options.url += `/versions/${packageVersion}`; } - const response = await request.del(options).catch(error => { this.logFailure(); throw error; }); //it's not clear why we are calling logFailure in two layers (here and in the usual try-catch around it) + const response = await request.del(options).catch(error => { this.logFailure(); throw request.getErrorMessage(null, error); }); //it's not clear why we are calling logFailure in two layers (here and in the usual try-catch around it) const body = response.body ?? {}; if (response.statusCode !== 204) { this.logFailure(); - const message = body.message ?? body.error ?? body; + const message = request.getErrorMessage(body, null); throw `Unpublishing failed: ${message}`; } this.logSuccess(); } catch (error) { - this.logFailure(); - throw error; + this.logFailure(); + throw error; } } diff --git a/src/view.js b/src/view.js index e169d095..fab10be8 100644 --- a/src/view.js +++ b/src/view.js @@ -73,11 +73,11 @@ View information about a package/theme.\ url: `${config.getAtomPackagesUrl()}/${packageName}`, json: true }; - + const response = await request.get(requestSettings); const body = response.body ?? {}; if (response.statusCode !== 200) { - const message = body.message ?? body.error ?? body; + const message = request.getErrorMessage(body, null); throw `Requesting package failed: ${message}`; }