+});
+
+/*
+ * This mechanism is used to notify the user of the first error encountered on the page. This
+ * was previously internal to Ext.Error.raise and is a desirable feature since errors often
+ * slip silently under the radar. It cannot live in Ext.Error.raise since there are times
+ * where exceptions are handled in a try/catch.
+ */
+//<debug>
+(function () {
+ var prevOnError, timer, errors = 0,
+ extraordinarilyBad = /(out of stack)|(too much recursion)|(stack overflow)|(out of memory)/i,
+ win = Ext.global;
+
+ if (typeof window === 'undefined') {
+ return; // build system or some such environment...
+ }
+
+ // This method is called to notify the user of the current error status.
+ function notify () {
+ var counters = Ext.log.counters,
+ supports = Ext.supports,
+ hasOnError = supports && supports.WindowOnError; // TODO - timing
+
+ // Put log counters to the status bar (for most browsers):
+ if (counters && (counters.error + counters.warn + counters.info + counters.log)) {
+ var msg = [ 'Logged Errors:',counters.error, 'Warnings:',counters.warn,
+ 'Info:',counters.info, 'Log:',counters.log].join(' ');
+ if (errors) {
+ msg = '*** Errors: ' + errors + ' - ' + msg;
+ } else if (counters.error) {
+ msg = '*** ' + msg;
+ }
+ win.status = msg;
+ }
+
+ // Display an alert on the first error:
+ if (!Ext.isDefined(Ext.Error.notify)) {
+ Ext.Error.notify = Ext.isIE6 || Ext.isIE7; // TODO - timing
+ }
+ if (Ext.Error.notify && (hasOnError ? errors : (counters && counters.error))) {
+ Ext.Error.notify = false;
+
+ if (timer) {
+ win.clearInterval(timer); // ticks can queue up so stop...
+ timer = null;
+ }
+
+ alert('Unhandled error on page: See console or log');
+ poll();
+ }
+ }
+
+ // Sets up polling loop. This is the only way to know about errors in some browsers
+ // (Opera/Safari) and is the only way to update the status bar for warnings and other
+ // non-errors.
+ function poll () {
+ timer = win.setInterval(notify, 1000);
+ }
+
+ // window.onerror is ideal (esp in IE) because you get full context. This is harmless
+ // otherwise (never called) which is good because you cannot feature detect it.
+ prevOnError = win.onerror || Ext.emptyFn;
+ win.onerror = function (message) {
+ ++errors;
+
+ if (!extraordinarilyBad.test(message)) {
+ // too much recursion + our alert right now = crash IE
+ // our polling loop will pick it up even if we don't alert now
+ notify();
+ }
+
+ return prevOnError.apply(this, arguments);
+ };
+ poll();
+})();
+//</debug>