2
0
mirror of https://github.com/frappe/books.git synced 2025-02-02 12:08:27 +00:00

feat: action only if autoReport is not active

This commit is contained in:
18alantom 2022-01-19 16:43:50 +05:30 committed by Alan
parent 5681e90665
commit c3c72470dc

View File

@ -15,6 +15,24 @@ function reportError(errorLogObj) {
console.log(errorLogObj); console.log(errorLogObj);
} }
function getToastProps(errorLogObj) {
const props = {
message: _(`Error: `) + errorLogObj.name,
type: 'error',
};
if (!frappe.SystemSettings.autoReportErrors) {
Object.assign(props, {
actionText: frappe._('Report Error'),
action: () => {
reportError(errorLogObj);
},
});
}
return props;
}
export function handleError(shouldLog, error, more = {}) { export function handleError(shouldLog, error, more = {}) {
if (shouldLog) { if (shouldLog) {
console.error(error); console.error(error);
@ -26,17 +44,13 @@ export function handleError(shouldLog, error, more = {}) {
const { name, stack, message } = error; const { name, stack, message } = error;
const errorLogObj = { name, stack, message, more }; const errorLogObj = { name, stack, message, more };
frappe.errorLog.push(errorLogObj); frappe.errorLog.push(errorLogObj);
// Do something cool showToast(getToastProps(errorLogObj));
showToast({ if (frappe.SystemSettings.autoReportErrors) {
message: _(`Error: `) + name, reportError(errorLogObj);
actionText: frappe._('Report Error'), }
type: 'error',
action: () => {
reportError(errorLogObj);
},
});
} }
export function getErrorMessage(e, doc) { export function getErrorMessage(e, doc) {