mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
🐛 Fixed 'Invalid status code: undefined' in members api (#15973)
fixes https://github.com/TryGhost/Team/issues/2377 When there is an error thrown that is not a Ghost error, there is no status code in the error. Calling res.writeHead with an undefined status code, throws an error and crashes Ghost. This change fixes that and adds logging for those errors.
This commit is contained in:
parent
520b19e313
commit
a721e4f2d7
1 changed files with 12 additions and 3 deletions
|
@ -77,7 +77,10 @@ const deleteSession = async function (req, res) {
|
|||
res.writeHead(204);
|
||||
res.end();
|
||||
} catch (err) {
|
||||
res.writeHead(err.statusCode, {
|
||||
if (!err.statusCode) {
|
||||
logging.error(err);
|
||||
}
|
||||
res.writeHead(err.statusCode ?? 500, {
|
||||
'Content-Type': 'text/plain;charset=UTF-8'
|
||||
});
|
||||
res.end(err.message);
|
||||
|
@ -111,7 +114,10 @@ const deleteSuppression = async function (req, res) {
|
|||
res.writeHead(204);
|
||||
res.end();
|
||||
} catch (err) {
|
||||
res.writeHead(err.statusCode, {
|
||||
if (!err.statusCode) {
|
||||
logging.error(err);
|
||||
}
|
||||
res.writeHead(err.statusCode ?? 500, {
|
||||
'Content-Type': 'text/plain;charset=UTF-8'
|
||||
});
|
||||
res.end(err.message);
|
||||
|
@ -194,7 +200,10 @@ const updateMemberData = async function (req, res) {
|
|||
res.json(null);
|
||||
}
|
||||
} catch (err) {
|
||||
res.writeHead(err.statusCode, {
|
||||
if (!err.statusCode) {
|
||||
logging.error(err);
|
||||
}
|
||||
res.writeHead(err.statusCode ?? 500, {
|
||||
'Content-Type': 'text/plain;charset=UTF-8'
|
||||
});
|
||||
res.end(err.message);
|
||||
|
|
Loading…
Add table
Reference in a new issue