🥅 Updates error catching functionality, to handle stack traces

This commit is contained in:
Alicia Sykes 2021-12-13 21:37:43 +00:00
parent aa770d6629
commit f9a0005740
2 changed files with 6 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* eslint no-console: ["error", { allow: ["log", "info"] }] */
/* eslint no-console: ["error", { allow: ["log", "info", "warn"] }] */
/* Prints the app name and version, helpful for debugging */
export const welcomeMsg = () => {
@ -7,13 +7,16 @@ export const welcomeMsg = () => {
};
/* Prints warning message, usually when there is a configuration error */
export const warningMsg = (message) => {
export const warningMsg = (message, stack) => {
console.info(
`\n%c⚠ Warning ⚠️%c \n${message} \n\n%cThis is likely not an issue with Dashy, but rather your configuration. If you think it is a bug, please open a ticket on GitHub: https://git.io/JukXk`,
"color:#ceb73f; background: #ceb73f33; font-size:1.5rem; padding:0.15rem; margin: 1rem auto; font-family: Rockwell, Tahoma, 'Trebuchet MS', Helvetica; border: 2px solid #ceb73f; border-radius: 4px; font-weight: bold; text-shadow: 1px 1px 1px #000000bf;",
'font-weight: bold; font-size: 1rem;color: #ceb73f;',
"color: #ceb73f; font-size: 0.75rem; font-family: Tahoma, 'Trebuchet MS', Helvetica;",
);
if (stack) {
console.warn(`%cStack Trace%c\n${stack}`, 'font-weight: bold;', '');
}
};
/* Prints status message */

View File

@ -24,9 +24,7 @@ const appendToErrorLog = (msg) => {
*/
const ErrorHandler = function handler(msg, errorStack) {
// Print to console
warningMsg(msg);
// If stack trace included, then print that too
if (errorStack) console.warn(errorStack); // eslint-disable-line no-console
warningMsg(msg, errorStack);
// Save to local storage
appendToErrorLog(msg);
// Report to bug tracker (if enabled)