repo-tools, create-app: replace duplicate error utilities with cli-common imports (#33893)

* Replace duplicate error utilities with @backstage/cli-common imports

Remove dead CustomError and ExitCodeError classes from repo-tools and
create-app, replacing them with the ExitCodeError import from
@backstage/cli-common. This fixes the instanceof check in exitWithError
so it actually catches errors thrown by cli-common's run().

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor

* Add changeset for repo-tools and create-app

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor

---------

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2026-04-15 14:39:42 +02:00
committed by GitHub
parent ba9717cf70
commit 927c0039d7
3 changed files with 8 additions and 38 deletions
@@ -0,0 +1,6 @@
---
'@backstage/repo-tools': patch
'@backstage/create-app': patch
---
Replaced internal error utilities with shared ones from `@backstage/cli-common`.
+1 -19
View File
@@ -14,27 +14,9 @@
* limitations under the License.
*/
import { ExitCodeError } from '@backstage/cli-common';
import chalk from 'chalk';
export class CustomError extends Error {
get name(): string {
return this.constructor.name;
}
}
export class ExitCodeError extends CustomError {
readonly code: number;
constructor(code: number, command?: string) {
if (command) {
super(`Command '${command}' exited with code ${code}`);
} else {
super(`Child exited with code ${code}`);
}
this.code = code;
}
}
export function exitWithError(error: Error): never {
if (error instanceof ExitCodeError) {
process.stderr.write(`\n${chalk.red(error.message)}\n\n`);
+1 -19
View File
@@ -14,27 +14,9 @@
* limitations under the License.
*/
import { ExitCodeError } from '@backstage/cli-common';
import chalk from 'chalk';
export class CustomError extends Error {
get name(): string {
return this.constructor.name;
}
}
export class ExitCodeError extends CustomError {
readonly code: number;
constructor(code: number, command?: string) {
super(
command
? `Command '${command}' exited with code ${code}`
: `Child exited with code ${code}`,
);
this.code = code;
}
}
export function exitWithError(error: Error): never {
if (error instanceof ExitCodeError) {
process.stderr.write(`\n${chalk.red(error.message)}\n\n`);