2013-11-14 14:44:57 -05:00
|
|
|
define(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var er = {};
|
|
|
|
er.attachHandler = function(scope) {
|
2014-04-23 06:20:46 -04:00
|
|
|
scope.onError = function(options) {
|
2013-11-14 14:44:57 -05:00
|
|
|
if (!options) {
|
2014-02-21 10:22:33 -05:00
|
|
|
scope.$apply();
|
2013-11-14 14:44:57 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-11 12:39:13 -04:00
|
|
|
if (options.stack) {
|
|
|
|
console.error(options.stack);
|
|
|
|
} else {
|
|
|
|
console.error(options);
|
|
|
|
}
|
2013-11-14 14:44:57 -05:00
|
|
|
|
|
|
|
scope.state.dialog = {
|
|
|
|
open: true,
|
|
|
|
title: options.title || 'Error',
|
2014-05-23 04:52:34 -04:00
|
|
|
message: options.errMsg || options.message,
|
|
|
|
positiveBtnStr: options.positiveBtnStr || 'Ok',
|
|
|
|
negativeBtnStr: options.negativeBtnStr || 'Cancel',
|
|
|
|
showNegativeBtn: options.showNegativeBtn || false,
|
|
|
|
callback: options.callback
|
2013-11-14 14:44:57 -05:00
|
|
|
};
|
2013-11-14 17:57:06 -05:00
|
|
|
// don't call apply for synchronous calls
|
|
|
|
if (!options.sync) {
|
|
|
|
scope.$apply();
|
|
|
|
}
|
2013-11-14 14:44:57 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
return er;
|
|
|
|
});
|