1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-11 19:55:06 -05:00
mail/src/js/util/error.js

35 lines
1.2 KiB
JavaScript
Raw Normal View History

define(function(require) {
'use strict';
var axe = require('axe');
var er = {};
er.attachHandler = function(scope) {
scope.onError = function(options) {
if (!options) {
scope.$apply();
return;
}
axe.error((options.errMsg || options.message) + (options.stack ? ('\n' + options.stack) : ''));
scope.state.dialog = {
open: true,
title: options.title || 'Error',
2014-05-23 04:52:34 -04:00
message: options.errMsg || options.message,
2014-08-12 11:44:10 -04:00
faqLink: options.faqLink,
2014-05-23 04:52:34 -04:00
positiveBtnStr: options.positiveBtnStr || 'Ok',
negativeBtnStr: options.negativeBtnStr || 'Cancel',
showNegativeBtn: options.showNegativeBtn || false,
2014-08-12 12:32:37 -04:00
showBugReporter: (typeof options.showBugReporter !== 'undefined' ? options.showBugReporter : !options.title), // if title is set, presume it's not an error by default
2014-05-23 04:52:34 -04:00
callback: options.callback
};
// don't call apply for synchronous calls
if (!options.sync) {
scope.$apply();
}
};
};
return er;
});