mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
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:
parent
3baf52fba9
commit
7a2398b7f2
@ -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);
|
||||
});
|
||||
};
|
||||
|
@ -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};
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user