MDL-57100 JS: Exceptions give exceptions
Exceptions returned from ajax are not in the format expected by the JS, so an error occurs and the exception popups are not appearing. Conflicts: lib/amd/build/notification.min.js lib/amd/src/notification.js
This commit is contained in:
committed by
Dan Poltawski
parent
ca86a178c8
commit
1cf01e8add
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define(["core/yui"],function(a){return{alert:function(b,c,d){a.use("moodle-core-notification-alert",function(){var a=new M.core.alert({title:b,message:c,yesLabel:d});a.show()})},confirm:function(b,c,d,e,f){a.use("moodle-core-notification-confirm",function(){var a=new M.core.confirm({title:b,question:c,yesLabel:d,noLabel:e});a.on("complete-yes",function(){f()}),a.show()})},exception:function(b){b.backtrace&&(b.lineNumber=b.backtrace[0].line,b.fileName=b.backtrace[0].file,b.fileName="..."+b.fileName.substr(b.fileName.length-20),b.stack=b.debuginfo,b.name=b.errorcode),a.use("moodle-core-notification-exception",function(){var a=new M.core.exception(b);a.show()})}}});
|
||||
define(["core/yui"],function(a){return{alert:function(b,c,d){a.use("moodle-core-notification-alert",function(){var a=new M.core.alert({title:b,message:c,yesLabel:d});a.show()})},confirm:function(b,c,d,e,f){a.use("moodle-core-notification-confirm",function(){var a=new M.core.confirm({title:b,question:c,yesLabel:d,noLabel:e});a.on("complete-yes",function(){f()}),a.show()})},exception:function(b){if("undefined"==typeof b.stack&&(b.stack=""),b.debuginfo&&(b.stack+=b.debuginfo+"\n"),b.backtrace){b.stack+=b.backtrace;var c=b.backtrace.match(/line ([^ ]*) of/),d=b.backtrace.match(/ of ([^:]*): /);c&&c[1]&&(b.lineNumber=c[1]),d&&d[1]&&(b.fileName=d[1],b.fileName.length>30&&(b.fileName="..."+b.fileName.substr(b.fileName.length-27)))}"undefined"==typeof b.name&&b.errorcode&&(b.name=b.errorcode),a.use("moodle-core-notification-exception",function(){var a=new M.core.exception(b);a.show()})}}});
|
||||
@@ -88,14 +88,31 @@ define(['core/yui'], function(Y) {
|
||||
*/
|
||||
exception: function(ex) {
|
||||
// Fudge some parameters.
|
||||
if (typeof ex.stack == 'undefined') {
|
||||
ex.stack = '';
|
||||
}
|
||||
if (ex.debuginfo) {
|
||||
ex.stack += ex.debuginfo + '\n';
|
||||
}
|
||||
if (ex.backtrace) {
|
||||
ex.lineNumber = ex.backtrace[0].line;
|
||||
ex.fileName = ex.backtrace[0].file;
|
||||
ex.fileName = '...' + ex.fileName.substr(ex.fileName.length - 20);
|
||||
ex.stack = ex.debuginfo;
|
||||
ex.stack += ex.backtrace;
|
||||
var ln = ex.backtrace.match(/line ([^ ]*) of/);
|
||||
var fn = ex.backtrace.match(/ of ([^:]*): /);
|
||||
if (ln && ln[1]) {
|
||||
ex.lineNumber = ln[1];
|
||||
}
|
||||
if (fn && fn[1]) {
|
||||
ex.fileName = fn[1];
|
||||
if (ex.fileName.length > 30) {
|
||||
ex.fileName = '...' + ex.fileName.substr(ex.fileName.length - 27);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof ex.name == 'undefined' && ex.errorcode) {
|
||||
ex.name = ex.errorcode;
|
||||
}
|
||||
Y.use('moodle-core-notification-exception', function () {
|
||||
|
||||
Y.use('moodle-core-notification-exception', function() {
|
||||
var modal = new M.core.exception(ex);
|
||||
|
||||
modal.show();
|
||||
|
||||
Reference in New Issue
Block a user