Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions apps/desktop/src/lib/trpc/routers/external/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { spawn } from "node:child_process";
import nodePath from "node:path";
import type { ExternalApp } from "@superset/local-db";
import { TRPCError } from "@trpc/server";

/** Map of app IDs to their macOS application names */
const MACOS_APP_NAMES: Record<ExternalApp, string | null> = {
Expand Down Expand Up @@ -384,11 +385,21 @@ export function spawnAsync(command: string, args: string[]): Promise<void> {
});

child.on("error", (error) => {
reject(
new Error(
`Failed to spawn '${command}': ${error.message}. Ensure the application is installed.`,
),
);
const message = `Failed to spawn '${command}': ${error.message}. Ensure the application is installed.`;
// ENOENT means the app's CLI launcher isn't installed / not on PATH —
// a user-environment condition, not a bug, so it must not surface as
// INTERNAL_SERVER_ERROR (which the Sentry middleware reports).
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
reject(
new TRPCError({
code: "PRECONDITION_FAILED",
message,
cause: { kind: "APP_NOT_INSTALLED", command },
}),
);
return;
}
reject(new Error(message));
});

child.on("exit", (code) => {
Expand Down
Loading