mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-09-20 20:44:47 -04:00
Feat: Use message to improve errror status code
This commit is contained in:
parent
e241728419
commit
3439074835
3 changed files with 31 additions and 25 deletions
|
@ -730,15 +730,27 @@ exports.filterAndJoin = (parts, connector = "") => {
|
|||
};
|
||||
|
||||
/**
|
||||
* Send a 403 response
|
||||
* Send an Error response
|
||||
* @param {Object} res Express response object
|
||||
* @param {string} [msg=""] Message to send
|
||||
*/
|
||||
module.exports.send403 = (res, msg = "") => {
|
||||
res.status(403).json({
|
||||
"status": "fail",
|
||||
"msg": msg,
|
||||
});
|
||||
module.exports.sendHttpError = (res, msg = "") => {
|
||||
if (msg.includes("SQLITE_BUSY") || msg.includes("SQLITE_LOCKED")) {
|
||||
res.status(503).json({
|
||||
"status": "fail",
|
||||
"msg": msg,
|
||||
});
|
||||
} else if (msg.toLowerCase().includes("not found")) {
|
||||
res.status(404).json({
|
||||
"status": "fail",
|
||||
"msg": msg,
|
||||
});
|
||||
} else {
|
||||
res.status(403).json({
|
||||
"status": "fail",
|
||||
"msg": msg,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function timeObjectConvertTimezone(obj, timezone, timeObjectToUTC = true) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue