Skip to content

Commit 7c96930

Browse files
committed
Enhance error handling with detailed error information
1 parent 65d84d0 commit 7c96930

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/build/src/extensions/python.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,19 @@ export const run = async (scriptArgs: string[] = [], options: ExecaOptions = {})
133133
})(pythonBin, scriptArgs);
134134

135135
try {
136-
assert(!result.failed, `Command failed: ${result.stderr}`);
137-
assert(result.exitCode === 0, `Non-zero exit code: ${result.exitCode}`);
136+
assert(!result.failed, `Python command failed: ${result.stderr}\nCommand: ${result.command}`);
137+
assert(
138+
result.exitCode === 0,
139+
`Python command exited with non-zero code ${result.exitCode}\nStdout: ${result.stdout}\nStderr: ${result.stderr}`
140+
);
138141
} catch (e) {
139-
logger.error(e.message, result);
142+
logger.error("Python command execution failed", {
143+
error: e.message,
144+
command: result.command,
145+
stdout: result.stdout,
146+
stderr: result.stderr,
147+
exitCode: result.exitCode,
148+
});
140149
throw e;
141150
}
142151

@@ -160,7 +169,7 @@ export const runInline = async (scriptContent: string, options: ExecaOptions = {
160169
// Create a temporary file with restricted permissions
161170
const tmpFile = `/tmp/script_${Date.now()}.py`;
162171
await fs.promises.writeFile(tmpFile, scriptContent, { mode: 0o600 });
163-
172+
164173
try {
165174
return await runScript(tmpFile, [], options);
166175
} finally {

0 commit comments

Comments
 (0)