Skip to content

Commit 12f9b63

Browse files
authored
Always print the full error (#60)
1 parent a13cb1d commit 12f9b63

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

cli.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,33 +120,37 @@ async function doPublish() {
120120
function errorHandler(error) {
121121
spinner.stop();
122122

123+
console.log(error?.response?.body ?? error);
124+
process.exitCode = 1;
125+
123126
if (error?.name === 'HTTPError') {
124127
const response = JSON.parse(error?.response?.body ?? '{}');
125128
const { clientId, refreshToken } = apiConfig;
126129
if (response.error_description === 'The OAuth client was not found.') {
127-
console.error('Error: `The OAuth client was not found`');
128130
console.error(
129131
'Probably the provided client ID is not valid. Try following the guide again',
130132
);
131133
console.error(
132134
'https://github.com/fregante/chrome-webstore-upload/blob/main/How%20to%20generate%20Google%20API%20keys.md',
133135
);
134136
console.error({ clientId });
135-
process.exitCode = 1;
136137
return;
137138
}
138139

139140
if (response.error_description === 'Bad Request') {
140141
const { clientId } = apiConfig;
141-
console.error('Error: `invalid_grant`');
142142
console.error(
143143
'Probably the provided refresh token is not valid. Try following the guide again',
144144
);
145145
console.error(
146146
'https://github.com/fregante/chrome-webstore-upload/blob/main/How%20to%20generate%20Google%20API%20keys.md',
147147
);
148148
console.error({ clientId, refreshToken });
149-
process.exitCode = 1;
149+
return;
150+
}
151+
152+
if (error?.message === 'Response code 400 (Bad Request)') {
153+
// Nothing else to add
150154
return;
151155
}
152156
}
@@ -156,14 +160,7 @@ function errorHandler(error) {
156160
console.error('Error: ' + itemError.error_code);
157161
console.error(itemError.error_detail);
158162
}
159-
160-
process.exitCode = 1;
161-
return;
162163
}
163-
164-
console.error('Error');
165-
console.error(error);
166-
process.exitCode = 1;
167164
}
168165

169166
async function init() {

0 commit comments

Comments
 (0)