mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +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)
|
||||
await new Promise((resolve, reject) => {
|
||||
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.stderr.on('data', (data) => { stdoutBuffer += data.toString(); });
|
||||
abiword.on('exit', (code) => {
|
||||
if (code !== 0) {
|
||||
return callback(`Abiword died with exit code ${code}`);
|
||||
}
|
||||
if (code !== 0) return callback(new Error(`Abiword died with exit code ${code}`));
|
||||
if (stdoutBuffer !== '') {
|
||||
console.log(stdoutBuffer);
|
||||
}
|
||||
|
@ -61,13 +59,13 @@ if (os.type().indexOf('Windows') > -1) {
|
|||
abiword.stderr.on('data', (data) => { stdoutBuffer += data.toString(); });
|
||||
abiword.on('exit', (code) => {
|
||||
spawnAbiword();
|
||||
stdoutCallback(`Abiword died with exit code ${code}`);
|
||||
stdoutCallback(new Error(`Abiword died with exit code ${code}`));
|
||||
});
|
||||
abiword.stdout.on('data', (data) => {
|
||||
stdoutBuffer += data.toString();
|
||||
// we're searching for the prompt, cause this means everything we need is in the buffer
|
||||
if (stdoutBuffer.search('AbiWord:>') !== -1) {
|
||||
const err = stdoutBuffer.search('OK') !== -1 ? null : stdoutBuffer;
|
||||
const err = stdoutBuffer.search('OK') !== -1 ? null : new Error(stdoutBuffer);
|
||||
stdoutBuffer = '';
|
||||
if (stdoutCallback != null && !firstPrompt) {
|
||||
stdoutCallback(err);
|
||||
|
|
|
@ -59,7 +59,8 @@ const doConvertTask = (task, callback) => {
|
|||
soffice.on('exit', (code) => {
|
||||
clearTimeout(hangTimeout);
|
||||
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();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue