mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
fix: extract error message from subprocess stdout on non-zero exit
This commit is contained in:
parent
ecbe505662
commit
e233dbd1ca
1 changed files with 7 additions and 1 deletions
|
|
@ -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 };
|
||||
|
|
|
|||
Loading…
Reference in a new issue