pointsight/functions.js

26 lines
753 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Rounds a number to ˋplacesˋ amount of digits
// Example roundOff(5.2434234234, 3) => 5.243
let roundOff = (num, places) => {
const x = Math.pow(10, places);
return Math.round(num * x) / x;
};
function handleMysqlErrors(err, title) {
if (err) {
if (err.code == "ECONNREFUSED") {
console.log(
"⚠ Connection to database failed. Is the database server running? ⚠"
);
process.exit(5);
} else if (err.code == "ECONNRESET") {
console.log("⚠ Module " + title + " experienced a connection reset ⚠");
process.exit(5);
} else {
console.warn("!!!!!!!!!!!!!!!! NOW THROWING " + err.code + " !!!!!!!!!!!!!!!!")
throw err;
}
}
}
module.exports = { roundOff, handleMysqlErrors };