Skip to content

Commit

Permalink
Merge pull request #285 from pantheon-systems/users/kestub/FixRecentC…
Browse files Browse the repository at this point in the history
…hanges

Fix delete site command name and success message. More flexible error messages from backend.
  • Loading branch information
kevinstubbs authored Jul 10, 2024
2 parents 5f70123 + 3f143f0 commit ca69e89
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/cli/src/cli/commands/sites/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const deleteSite = errorHandler<{
}>(async ({ id, transferToSiteId, force }) => {
const spinner = ora("Deleting site...").start();
try {
const siteId = await AddOnApiHelper.deleteSite(id, transferToSiteId, force);
spinner.succeed(`Successfully deleted the site with id "${siteId}"`);
await AddOnApiHelper.deleteSite(id, transferToSiteId, force);
spinner.succeed(`Successfully deleted the site with id "${id}"`);
} catch (e) {
spinner.fail();
throw e;
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/cli/exceptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ export function errorHandler<T>(
if (
axios.isAxiosError(e) &&
(e.response?.status ?? 500) < 500 && // Treat internal server errors as unhandled errors
e.response?.data?.message
e.response?.data
) {
// Operational error
console.log(chalk.red(`\nError: ${e.response.data.message}`));
console.log(
chalk.red(`\nError: ${e.response.data.message || e.response.data}`),
);
} else {
// Unhandled error
console.log(
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ yargs(hideBin(process.argv))
async (args) => await createSite(args.url as string),
)
.command(
"create [options]",
"delete [options]",
"Delete site.",
(yargs) => {
yargs.option("id", {
Expand Down

0 comments on commit ca69e89

Please sign in to comment.