mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
import/export: Use Error objects for errors, not strings
This commit is contained in:
parent
59c167e31b
commit
216aecd433
3 changed files with 6 additions and 7 deletions
|
@ -102,7 +102,7 @@ exports.doExport = async (req, res, padId, readOnlyId, type) => {
|
||||||
// @TODO no Promise interface for convertors (yet)
|
// @TODO no Promise interface for convertors (yet)
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
convertor.convertFile(srcFile, destFile, type, (err) => {
|
convertor.convertFile(srcFile, destFile, type, (err) => {
|
||||||
err ? reject('convertFailed') : resolve();
|
err ? reject(new Error('convertFailed')) : resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,7 @@ if (os.type().indexOf('Windows') > -1) {
|
||||||
abiword.stdout.on('data', (data) => { stdoutBuffer += data.toString(); });
|
abiword.stdout.on('data', (data) => { stdoutBuffer += data.toString(); });
|
||||||
abiword.stderr.on('data', (data) => { stdoutBuffer += data.toString(); });
|
abiword.stderr.on('data', (data) => { stdoutBuffer += data.toString(); });
|
||||||
abiword.on('exit', (code) => {
|
abiword.on('exit', (code) => {
|
||||||
if (code !== 0) {
|
if (code !== 0) return callback(new Error(`Abiword died with exit code ${code}`));
|
||||||
return callback(`Abiword died with exit code ${code}`);
|
|
||||||
}
|
|
||||||
if (stdoutBuffer !== '') {
|
if (stdoutBuffer !== '') {
|
||||||
console.log(stdoutBuffer);
|
console.log(stdoutBuffer);
|
||||||
}
|
}
|
||||||
|
@ -61,13 +59,13 @@ if (os.type().indexOf('Windows') > -1) {
|
||||||
abiword.stderr.on('data', (data) => { stdoutBuffer += data.toString(); });
|
abiword.stderr.on('data', (data) => { stdoutBuffer += data.toString(); });
|
||||||
abiword.on('exit', (code) => {
|
abiword.on('exit', (code) => {
|
||||||
spawnAbiword();
|
spawnAbiword();
|
||||||
stdoutCallback(`Abiword died with exit code ${code}`);
|
stdoutCallback(new Error(`Abiword died with exit code ${code}`));
|
||||||
});
|
});
|
||||||
abiword.stdout.on('data', (data) => {
|
abiword.stdout.on('data', (data) => {
|
||||||
stdoutBuffer += data.toString();
|
stdoutBuffer += data.toString();
|
||||||
// we're searching for the prompt, cause this means everything we need is in the buffer
|
// we're searching for the prompt, cause this means everything we need is in the buffer
|
||||||
if (stdoutBuffer.search('AbiWord:>') !== -1) {
|
if (stdoutBuffer.search('AbiWord:>') !== -1) {
|
||||||
const err = stdoutBuffer.search('OK') !== -1 ? null : stdoutBuffer;
|
const err = stdoutBuffer.search('OK') !== -1 ? null : new Error(stdoutBuffer);
|
||||||
stdoutBuffer = '';
|
stdoutBuffer = '';
|
||||||
if (stdoutCallback != null && !firstPrompt) {
|
if (stdoutCallback != null && !firstPrompt) {
|
||||||
stdoutCallback(err);
|
stdoutCallback(err);
|
||||||
|
|
|
@ -59,7 +59,8 @@ const doConvertTask = (task, callback) => {
|
||||||
soffice.on('exit', (code) => {
|
soffice.on('exit', (code) => {
|
||||||
clearTimeout(hangTimeout);
|
clearTimeout(hangTimeout);
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
return callback(`LibreOffice died with exit code ${code} and message: ${stdoutBuffer}`);
|
return callback(
|
||||||
|
new Error(`LibreOffice died with exit code ${code} and message: ${stdoutBuffer}`));
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue