Skip to content

Commit 81c088d

Browse files
feat: pretty error message when app upload gets 403 [5872] (#2359)
* feat: pretty error message when app upload gets 403. fix: Catch error message that is not standard format * fix: Mixing things up * Update packages/contentful--app-scripts/src/upload/create-app-bundle.ts Co-authored-by: Jared Jolton <145477871+jjolton-contentful@users.noreply.github.com> --------- Co-authored-by: Jared Jolton <145477871+jjolton-contentful@users.noreply.github.com>
1 parent c017536 commit 81c088d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/contentful--app-scripts/src/upload/create-app-bundle.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@ export async function createAppBundleFromUpload(settings: UploadSettings, appUpl
2727
functions,
2828
});
2929
} catch (err: any) {
30-
showCreationError('app upload', err.message);
30+
try {
31+
const message = JSON.parse(err.message);
32+
if (message['status'] == 403 && message.details?.reasons) {
33+
showCreationError('app upload', message['details']['reasons']);
34+
} else {
35+
showCreationError('app upload', message);
36+
}
37+
} catch (e) {
38+
showCreationError('app upload', err.message);
39+
}
3140
}
3241
bundleSpinner.stop();
3342
return appBundle;

0 commit comments

Comments
 (0)