2
* A dialogue type designed to display an appropriate error when an error
3
* thrown in the Moodle codebase was reported during an AJAX request.
5
* @module moodle-core-notification
6
* @submodule moodle-core-notification-ajaxexception
9
var AJAXEXCEPTION_NAME = 'Moodle AJAX exception',
13
* Extends core Dialogue to show the exception dialogue.
15
* @param {Object} config Object literal specifying the dialogue configuration properties.
17
* @class M.core.ajaxException
18
* @extends M.core.dialogue
20
AJAXEXCEPTION = function(config) {
21
config.name = config.name || 'Error';
22
config.closeButton = true;
23
AJAXEXCEPTION.superclass.constructor.apply(this, [config]);
25
Y.extend(AJAXEXCEPTION, M.core.dialogue, {
27
initializer : function(config) {
30
delay = this.get('hideTimeoutDelay');
31
this.get(BASE).addClass('moodle-dialogue-exception');
32
this.setStdModContent(Y.WidgetStdMod.HEADER,
33
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + config.name + '</h1>', Y.WidgetStdMod.REPLACE);
34
content = Y.Node.create('<div class="moodle-ajaxexception"></div>')
35
.append(Y.Node.create('<div class="moodle-exception-message">'+this.get('error')+'</div>'))
36
.append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>URL:</label> ' +
37
this.get('reproductionlink')+'</div>'))
38
.append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>Debug info:</label> ' +
39
this.get('debuginfo')+'</div>'))
40
.append(Y.Node.create('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>' +
41
this.get('stacktrace')+'</pre></div>'));
42
if (M.cfg.developerdebug) {
43
content.all('.moodle-exception-param').removeClass('hidden');
45
this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
48
this._hideTimeout = setTimeout(function(){self.hide();}, delay);
50
this.after('visibleChange', this.visibilityChanged, this);
51
this._keypress = Y.on('key', this.hide, window, 'down:13, 27', this);
52
this.centerDialogue();
54
visibilityChanged : function(e) {
55
if (e.attrName === 'visible' && e.prevVal && !e.newVal) {
57
this._keypress.detach();
58
setTimeout(function(){self.destroy();}, 1000);
62
NAME : AJAXEXCEPTION_NAME,
63
CSS_PREFIX : DIALOGUE_PREFIX,
67
* The error message given in the exception.
71
* @default 'Unknown error'
75
validator : Y.Lang.isString,
76
value : 'Unknown error'
80
* Any additional debug information given in the exception.
82
* @attribute stacktrace
92
* The complete stack trace provided in the exception.
94
* @attribute stacktrace
104
* A link which may be used by support staff to replicate the issue.
106
* @attribute reproductionlink
112
setter : function(link) {
114
link = '<a href="'+link+'">'+link.replace(M.cfg.wwwroot, '')+'</a>';
122
* If set, the dialogue is hidden after the specified timeout period.
124
* @attribute hideTimeoutDelay
130
validator : Y.Lang.isNumber,
136
M.core.ajaxException = AJAXEXCEPTION;