Skip to content

Commit

Permalink
Merge pull request #528 from LordSputnik/editor-server-cleanup
Browse files Browse the repository at this point in the history
Editor server cleanup
  • Loading branch information
MonkeyDo committed Nov 9, 2020
2 parents 71a0f5f + 4d6fa06 commit 76331e1
Show file tree
Hide file tree
Showing 2 changed files with 323 additions and 321 deletions.
24 changes: 14 additions & 10 deletions src/server/helpers/handler.js
Expand Up @@ -21,16 +21,20 @@ import * as error from '../../common/helpers/error';
import log from 'log';


export function sendPromiseResult(res, promise, processingCallback) {
return promise
.then((result) => {
res.send(result);
export async function sendPromiseResult(response, promise, processingCallback) {
const result = await promise;

if (typeof processingCallback === 'function') {
return processingCallback(result);
}
try {
response.send(result);

return result;
})
.catch((err) => { log.error(err); return error.sendErrorAsJSON(res, err); });
if (typeof processingCallback === 'function') {
return processingCallback(result);
}

return result;
}
catch (err) {
log.error(err);
return error.sendErrorAsJSON(response, err);
}
}

0 comments on commit 76331e1

Please sign in to comment.