2
0
mirror of https://github.com/frappe/books.git synced 2024-11-12 16:36:27 +00:00

feat: show Toast to report error

This commit is contained in:
18alantom 2022-01-19 16:29:13 +05:30 committed by Alan
parent 9e25b89765
commit 5681e90665

View File

@ -2,7 +2,7 @@ import { ipcRenderer } from 'electron';
import frappe from 'frappejs';
import { MandatoryError, ValidationError } from 'frappejs/common/errors';
import { IPC_ACTIONS } from './messages';
import { showMessageDialog } from './utils';
import { showMessageDialog, showToast } from './utils';
function shouldNotStore(error) {
return [MandatoryError, ValidationError].some(
@ -10,6 +10,11 @@ function shouldNotStore(error) {
);
}
function reportError(errorLogObj) {
// push errorlog to frappebooks.com
console.log(errorLogObj);
}
export function handleError(shouldLog, error, more = {}) {
if (shouldLog) {
console.error(error);
@ -24,6 +29,14 @@ export function handleError(shouldLog, error, more = {}) {
frappe.errorLog.push(errorLogObj);
// Do something cool
showToast({
message: _(`Error: `) + name,
actionText: frappe._('Report Error'),
type: 'error',
action: () => {
reportError(errorLogObj);
},
});
}
export function getErrorMessage(e, doc) {