-
Bug
-
Resolution: Fixed
-
Major
-
3.2, 3.3
-
MOODLE_32_STABLE, MOODLE_33_STABLE
-
MOODLE_32_STABLE, MOODLE_33_STABLE
-
MDL-59312-master -
We aren't passing the error object through so we can display more information about AJAX requests.
Example:
- An ill formatted response
- A cancelled request (from page unload)
In these occasions an Error is thrown by the JS (or native) code.
The requestFail code in lib/amd/src/ajax.js is passed the Error, along with the name of the error that was thrown (e.g. parseerror).
Unfortunately the requestFail code does not use the Error object, and instead passes just the error string into the promise rejection.
In most cases a promise failure for our AJAX uses are passed straight to notification.exception.
However, notification.exception expects an Error object rather than a string, and it passes the value, after minor modifications, to moodle-core-notification-exception.
The YUI module (moodle-core-notification-exception) also expects an object, and it sets the content of the dialogue using that object, for example:
'<h1 id="moodle-dialogue-' + config.COUNT + '-header-text">' + Y.Escape.html(config.name) + '</h1>',
|
Since config should be an Error, but is actually a string, config.name returns as undefined - hence the confusing error message.
In order to solve this we need to:
- take the additional argument into requestFail and pass it as an argument in the rejection; and
- take the additional argument into notification.exception and replace the first argument with it if the first arg is a string.
If neither of the args are Error objects, then we should convert the string into an object with a value of name as a final fallback.
- Discovered while testing
-
MDL-58310 Error occurs whenever in progress ajax request is cancelled (random "undefined" popup)
- Closed
- has a non-specific relationship to
-
MDL-57103 Exceptions are not handled in ajax requests
- Closed
- has been marked as being related by
-
MDL-60603 Undefined error message popup
- Closed
- is blocked by
-
MDL-58310 Error occurs whenever in progress ajax request is cancelled (random "undefined" popup)
- Closed
- Testing discovered
-
MDL-59315 Remove unneccessary notification.exception calls
- Closed