Fixed error handling for API frame

no issue

- throwing an object from a catch handler is not a good idea
- unexpected and broke functional call to API (always returned a 500, because API returned {err: err, method: ...}
This commit is contained in:
kirrg001 2019-02-25 19:11:16 +01:00 committed by Katharina Irrgang
parent 3baf52fba9
commit 7a2398b7f2
2 changed files with 9 additions and 5 deletions

View File

@ -79,8 +79,12 @@ const http = (apiImpl, apiType) => {
debug('json response');
res.json(result || {});
})
.catch(({err, docName, method}) => {
req.frameOptions = {docName, method};
.catch((err) => {
req.frameOptions = {
docName: frame.docName,
method: frame.method
};
next(err);
});
};

View File

@ -138,6 +138,9 @@ const pipeline = (apiController, apiUtils) => {
return apiImpl(frame);
}
frame.docName = docName;
frame.method = method;
return Promise.resolve()
.then(() => {
return STAGES.validation.input(apiUtils, apiConfig, apiImpl, frame);
@ -156,9 +159,6 @@ const pipeline = (apiController, apiUtils) => {
})
.then(() => {
return frame.response;
})
.catch((err) => {
throw {err, docName, method};
});
};