mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
feat: error handle ipcRenderer.[send, invoke]
This commit is contained in:
parent
7b61eec372
commit
f8c76603d2
@ -22,3 +22,33 @@ export function handleError(shouldLog, error, more = {}) {
|
||||
|
||||
// Do something cool
|
||||
}
|
||||
|
||||
export function getErrorHandled(func) {
|
||||
return async function errorHandled(...args) {
|
||||
try {
|
||||
return await func(...args);
|
||||
} catch (error) {
|
||||
handleError(false, error, {
|
||||
functionName: func.name,
|
||||
functionArgs: args,
|
||||
});
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function getErrorHandledSync(func) {
|
||||
return function errorHandledSync(...args) {
|
||||
try {
|
||||
return func(...args);
|
||||
} catch (error) {
|
||||
handleError(false, error, {
|
||||
functionName: func.name,
|
||||
functionArgs: args,
|
||||
});
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import Vue from 'vue';
|
||||
import models from '../models';
|
||||
import App from './App';
|
||||
import FeatherIcon from './components/FeatherIcon';
|
||||
import { handleError } from './errorHandling';
|
||||
import { getErrorHandled, handleError } from './errorHandling';
|
||||
import { IPC_MESSAGES } from './messages';
|
||||
import router from './router';
|
||||
import { outsideClickDirective } from './ui';
|
||||
@ -16,6 +16,9 @@ import { stringifyCircular } from './utils';
|
||||
frappe.initializeAndRegister(models);
|
||||
frappe.fetch = window.fetch.bind();
|
||||
|
||||
ipcRenderer.send = getErrorHandled(ipcRenderer.send);
|
||||
ipcRenderer.invoke = getErrorHandled(ipcRenderer.invoke);
|
||||
|
||||
frappe.events.on('reload-main-window', () => {
|
||||
ipcRenderer.send(IPC_MESSAGES.RELOAD_MAIN_WINDOW);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user