Skip to content

Commit

Permalink
Always print the full error (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Apr 14, 2022
1 parent a13cb1d commit 12f9b63
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,33 +120,37 @@ async function doPublish() {
function errorHandler(error) {
spinner.stop();

console.log(error?.response?.body ?? error);
process.exitCode = 1;

if (error?.name === 'HTTPError') {
const response = JSON.parse(error?.response?.body ?? '{}');
const { clientId, refreshToken } = apiConfig;
if (response.error_description === 'The OAuth client was not found.') {
console.error('Error: `The OAuth client was not found`');
console.error(
'Probably the provided client ID is not valid. Try following the guide again',
);
console.error(
'https://github.com/fregante/chrome-webstore-upload/blob/main/How%20to%20generate%20Google%20API%20keys.md',
);
console.error({ clientId });
process.exitCode = 1;
return;
}

if (response.error_description === 'Bad Request') {
const { clientId } = apiConfig;
console.error('Error: `invalid_grant`');
console.error(
'Probably the provided refresh token is not valid. Try following the guide again',
);
console.error(
'https://github.com/fregante/chrome-webstore-upload/blob/main/How%20to%20generate%20Google%20API%20keys.md',
);
console.error({ clientId, refreshToken });
process.exitCode = 1;
return;
}

if (error?.message === 'Response code 400 (Bad Request)') {
// Nothing else to add
return;
}
}
Expand All @@ -156,14 +160,7 @@ function errorHandler(error) {
console.error('Error: ' + itemError.error_code);
console.error(itemError.error_detail);
}

process.exitCode = 1;
return;
}

console.error('Error');
console.error(error);
process.exitCode = 1;
}

async function init() {
Expand Down

0 comments on commit 12f9b63

Please sign in to comment.