Skip to content

Commit

Permalink
fix: throw error is failed conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatiny committed Jan 22, 2024
1 parent b221716 commit 574af4c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions docker/src/v1/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ async function doConvert(request, response) {
flags.push(`-i${body.inputFormat.replace(/ .*/, '')}`);
flags.push(`-o${body.outputFormat.replace(/ .*/, '')}`);

const result = spawnSync(BABEL, flags, {
stdio: ['pipe', 'pipe', 'pipe'],
input: body.input,
encoding: 'utf-8',
timeout: 10000,
});
try {
const result = spawnSync(BABEL, flags, {
stdio: ['pipe', 'pipe', 'pipe'],
input: body.input,
encoding: 'utf-8',
timeout: 10000,
});

response.send({ result: result.stdout, log: result.stderr });
response.send({ result: result.stdout, log: result.stderr });
} catch (e) {
response.send({ result: {}, log: e.toString() });
}
}

0 comments on commit 574af4c

Please sign in to comment.