Adding ability to send error object to notify() (#2955)
This commit is contained in:
parent
4aedb6b9a0
commit
32626bd2ab
6 changed files with 39 additions and 35 deletions
|
|
@ -15,9 +15,7 @@ const _syntaxValidation = function(cfg) {
|
|||
try {
|
||||
return new vm.Script(cfg, {filename: '.hyper.js', displayErrors: true});
|
||||
} catch (err) {
|
||||
notify('Error loading config:', `${err.name}, see DevTools for more info`);
|
||||
//eslint-disable-next-line no-console
|
||||
console.error('Error loading config:', err);
|
||||
notify('Error loading config:', `${err.name}, see DevTools for more info`, {error: err});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,13 @@ app.on('ready', () => {
|
|||
});
|
||||
});
|
||||
|
||||
function notify(title, body) {
|
||||
function notify(title, body, details = {}) {
|
||||
//eslint-disable-next-line no-console
|
||||
console.log(`[Notification] ${title}: ${body}`);
|
||||
if (details.error) {
|
||||
//eslint-disable-next-line no-console
|
||||
console.error(details.error);
|
||||
}
|
||||
if (win) {
|
||||
win.webContents.send('notification', {title, body});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ function updatePlugins({force = false} = {}) {
|
|||
|
||||
if (err) {
|
||||
//eslint-disable-next-line no-console
|
||||
notify('Error updating plugins.', err);
|
||||
notify('Error updating plugins.', err, {error: err});
|
||||
} else {
|
||||
// flag successful plugin update
|
||||
cache.set('hyper.plugins', id_);
|
||||
|
|
@ -257,9 +257,7 @@ function requirePlugins() {
|
|||
//eslint-disable-next-line no-console
|
||||
console.warn(`Plugin "${basename(path_)}" not found: ${path_}`);
|
||||
} else {
|
||||
//eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
notify('Plugin error!', `Plugin "${basename(path_)}" failed to load (${err.message})`);
|
||||
notify('Plugin error!', `Plugin "${basename(path_)}" failed to load (${err.message})`, {error: err});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -276,7 +274,9 @@ exports.onApp = app_ => {
|
|||
try {
|
||||
plugin.onApp(app_);
|
||||
} catch (e) {
|
||||
notify('Plugin error!', `"${plugin._name}" has encountered an error. Check Developer Tools for details.`);
|
||||
notify('Plugin error!', `"${plugin._name}" has encountered an error. Check Developer Tools for details.`, {
|
||||
error: e
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -288,7 +288,9 @@ exports.onWindow = win => {
|
|||
try {
|
||||
plugin.onWindow(win);
|
||||
} catch (e) {
|
||||
notify('Plugin error!', `"${plugin._name}" has encountered an error. Check Developer Tools for details.`);
|
||||
notify('Plugin error!', `"${plugin._name}" has encountered an error. Check Developer Tools for details.`, {
|
||||
error: e
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -304,7 +306,7 @@ function decorateObject(base, key) {
|
|||
try {
|
||||
res = plugin[key](decorated);
|
||||
} catch (e) {
|
||||
notify('Plugin error!', `"${plugin._name}" when decorating ${key}`);
|
||||
notify('Plugin error!', `"${plugin._name}" when decorating ${key}`, {error: e});
|
||||
return;
|
||||
}
|
||||
if (res && typeof res === 'object') {
|
||||
|
|
@ -330,7 +332,9 @@ exports.getDeprecatedConfig = () => {
|
|||
try {
|
||||
configTmp = plugin.decorateConfig(JSON.parse(JSON.stringify(baseConfig)));
|
||||
} catch (e) {
|
||||
notify('Plugin error!', `"${plugin._name}" has encountered an error. Check Developer Tools for details.`);
|
||||
notify('Plugin error!', `"${plugin._name}" has encountered an error. Check Developer Tools for details.`, {
|
||||
error: e
|
||||
});
|
||||
return;
|
||||
}
|
||||
const pluginCSSDeprecated = config.getDeprecatedCSS(configTmp);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue