Skip to content

Commit

Permalink
fix: better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoobes committed Nov 4, 2023
1 parent a309c08 commit 5dbf2a8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/create-publish.mts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ const res = await rest.updateGlobal(globalCommands);

let globalCommandsResponse: unknown;


if (res.ok) {
globalCommands.length && spin.succeed(`All ${cyanBright('Global')} commands published`);
globalCommandsResponse = await res.json();
Expand All @@ -199,15 +200,17 @@ if (res.ok) {
case 429:
throw Error('Chill out homie, too many requests')
}
console.error(
'errors:',
await res.json().then((res) => {
const errors = Object.values(res.errors);
// @ts-ignore
return errors.map((err) => err?.name?._errors);
})
console.error('errors:',
await res
.json()
.then((res) => {
const errors = Object.values(res?.errors ?? {});
// @ts-ignore
return errors.map((err) => err?.name?._errors);
})
.catch(() => "No errors found (Unparsable json for a request with bad status code). Read the status code.")
);
console.error(res.statusText);
console.error("Status Text ", res.statusText);
}

function associateGuildIdsWithData(data: PublishableModule[]): Map<string, PublishableData[]> {
Expand Down

0 comments on commit 5dbf2a8

Please sign in to comment.