mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-09-07 09:51:57 +00:00
![Matthew Nickson](/assets/img/avatar_default.png)
* Added JSDoc to eslint rules Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Fixed JSDoc eslint errors Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Update the check-linters workflow to Node.js 20 --------- Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
class NotificationProvider {
|
|
|
|
/**
|
|
* Notification Provider Name
|
|
* @type {string}
|
|
*/
|
|
name = undefined;
|
|
|
|
/**
|
|
* Send a notification
|
|
* @param {BeanModel} notification Notification to send
|
|
* @param {string} msg General Message
|
|
* @param {?object} monitorJSON Monitor details (For Up/Down only)
|
|
* @param {?object} heartbeatJSON Heartbeat details (For Up/Down only)
|
|
* @returns {Promise<string>} Return Successful Message
|
|
* @throws Error with fail msg
|
|
*/
|
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
|
throw new Error("Have to override Notification.send(...)");
|
|
}
|
|
|
|
/**
|
|
* Throws an error
|
|
* @param {any} error The error to throw
|
|
* @returns {void}
|
|
* @throws {any} The error specified
|
|
*/
|
|
throwGeneralAxiosError(error) {
|
|
let msg = "Error: " + error + " ";
|
|
|
|
if (error.response && error.response.data) {
|
|
if (typeof error.response.data === "string") {
|
|
msg += error.response.data;
|
|
} else {
|
|
msg += JSON.stringify(error.response.data);
|
|
}
|
|
}
|
|
|
|
throw new Error(msg);
|
|
}
|
|
}
|
|
|
|
module.exports = NotificationProvider;
|