diff --git a/apps/t3/src/cli.ts b/apps/t3/src/cli.ts index dc2198fa11..0328b75bac 100644 --- a/apps/t3/src/cli.ts +++ b/apps/t3/src/cli.ts @@ -343,8 +343,16 @@ export function validateLaunchDirectory(launchCwd: string): string { let stats: fs.Stats; try { stats = fs.statSync(resolved); - } catch { - throw new Error(`Launch directory does not exist: ${resolved}`); + } catch (error) { + const code = (error as NodeJS.ErrnoException | undefined)?.code; + if (code && code !== "ENOENT") { + throw new Error(`Failed to access launch directory: ${resolved} (${code})`, { + cause: error, + }); + } + throw new Error(`Launch directory does not exist: ${resolved}`, { + cause: error, + }); } if (!stats.isDirectory()) { diff --git a/apps/t3/src/runtimeApiServer.ts b/apps/t3/src/runtimeApiServer.ts index 6808d9b9f6..035aa8bdf9 100644 --- a/apps/t3/src/runtimeApiServer.ts +++ b/apps/t3/src/runtimeApiServer.ts @@ -325,8 +325,16 @@ function resolveExistingDirectory(targetPath: string, label: string): string { let stats: fs.Stats; try { stats = fs.statSync(candidate); - } catch { - throw new Error(`${label} does not exist: ${candidate}`); + } catch (error) { + const code = (error as NodeJS.ErrnoException | undefined)?.code; + if (code && code !== "ENOENT") { + throw new Error(`Failed to access ${label.toLowerCase()}: ${candidate} (${code})`, { + cause: error, + }); + } + throw new Error(`${label} does not exist: ${candidate}`, { + cause: error, + }); } if (!stats.isDirectory()) { @@ -347,8 +355,16 @@ function resolveExistingDirectoryFromBase( let stats: fs.Stats; try { stats = fs.statSync(candidate); - } catch { - throw new Error(`${label} does not exist: ${candidate}`); + } catch (error) { + const code = (error as NodeJS.ErrnoException | undefined)?.code; + if (code && code !== "ENOENT") { + throw new Error(`Failed to access ${label.toLowerCase()}: ${candidate} (${code})`, { + cause: error, + }); + } + throw new Error(`${label} does not exist: ${candidate}`, { + cause: error, + }); } if (!stats.isDirectory()) {