From 20c0677cab4093eb64452502276ef23ec2778f6d Mon Sep 17 00:00:00 2001 From: egalitarian11 Date: Wed, 1 Feb 2017 13:01:38 -0500 Subject: [PATCH 1/2] Handle 404 in upload.js Currently if a 404 is returned you get a json parsing error as seen in driftyco/ionic-cli#1765 which is entirely unhelpful and pretty confusing. This change will show that a 404 was received and give relevant information to whoever gets the error. Something should probably be done to generally handle any case where the API will return HTML instead of JSON, but this will help alleviate some confusion in the mean time. --- lib/upload.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/upload.js b/lib/upload.js index 1762860..a5ec18e 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -299,7 +299,9 @@ Upload.getDirectUploadKey = function getDirectUploadKey(project, jar, note) { return q.reject('Session expired (401). Please log in and run this command again.'); } else if (parseInt(response.statusCode, 10) === 403) { return q.reject('Forbidden upload (403)'); - } else if (parseInt(response.statusCode, 10) === 500) { + } else if (parseInt(response.statusCode, 10) === 404) { + return q.reject('App ID not found (404)'); + }else if (parseInt(response.statusCode, 10) === 500) { return q.reject('Server Error (500) :('); } else if (parseInt(response.statusCode, 10) === 522) { return q.reject('Connection timed out (522) :('); From 17bf685331d402bc4d49ecdb5b4faea1bec69ed0 Mon Sep 17 00:00:00 2001 From: egalitarian11 Date: Wed, 1 Feb 2017 13:05:03 -0500 Subject: [PATCH 2/2] Fix spacing --- lib/upload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/upload.js b/lib/upload.js index a5ec18e..e2213db 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -301,7 +301,7 @@ Upload.getDirectUploadKey = function getDirectUploadKey(project, jar, note) { return q.reject('Forbidden upload (403)'); } else if (parseInt(response.statusCode, 10) === 404) { return q.reject('App ID not found (404)'); - }else if (parseInt(response.statusCode, 10) === 500) { + } else if (parseInt(response.statusCode, 10) === 500) { return q.reject('Server Error (500) :('); } else if (parseInt(response.statusCode, 10) === 522) { return q.reject('Connection timed out (522) :(');