fix: extract error message from subprocess stdout on non-zero exit

This commit is contained in:
Research Assistant 2026-05-21 00:02:25 +08:00
parent ecbe505662
commit e233dbd1ca

View file

@ -567,7 +567,13 @@ function _runAnnotationSubprocess(vaultPath, args) {
var py = memoryState.getCachedPython(vaultPath);
if (!py) return Promise.resolve({ ok: false, error: 'Python not configured' });
return runSubprocess(py.path, args, vaultPath, 30000).then(function (result) {
if (result.exitCode !== 0) return { ok: false, error: result.stderr || 'Subprocess failed' };
if (result.exitCode !== 0) {
try {
var errBody = JSON.parse(result.stdout);
if (errBody && errBody.error && errBody.error.message) return { ok: false, error: errBody.error.message };
} catch (_) {}
return { ok: false, error: result.stderr || 'Subprocess failed' };
}
try {
var parsed = JSON.parse(result.stdout);
if (parsed && parsed.ok) return { ok: true, data: parsed.data || parsed.result };