mirror of
https://github.com/frappe/books.git
synced 2024-11-14 01:14:03 +00:00
feat: show Toast to report error
This commit is contained in:
parent
9e25b89765
commit
5681e90665
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user