diff --git a/IPython/html/static/base/js/utils.js b/IPython/html/static/base/js/utils.js
index 5ea6705..7e8d4be 100644
--- a/IPython/html/static/base/js/utils.js
+++ b/IPython/html/static/base/js/utils.js
@@ -5,7 +5,8 @@ define([
'base/js/namespace',
'jquery',
'codemirror/lib/codemirror',
-], function(IPython, $, CodeMirror){
+ 'components/rsvp/rsvp.min',
+], function(IPython, $, CodeMirror, rsvp){
"use strict";
IPython.load_extensions = function () {
@@ -606,13 +607,41 @@ define([
});
};
+ var WrappedError = function(message, error){
+ // Wrappable Error class
+
+ // The Error class doesn't actually act on `this`. Instead it always
+ // returns a new instance of Error. Here we capture that instance so we
+ // can apply it's properties to `this`.
+ var tmp = Error.apply(this, [message]);
+
+ // Copy the properties of the error over to this.
+ var properties = Object.getOwnPropertyNames(tmp);
+ for (var i = 0; i < properties.length; i++) {
+ this[properties[i]] = tmp[properties[i]];
+ }
+
+ // Keep a stack of the original error messages.
+ if (error instanceof WrappedError) {
+ this.error_stack = error.error_stack;
+ } else {
+ this.error_stack = [error];
+ }
+ this.error_stack.push(tmp);
+
+ return this;
+ };
+
+ WrappedError.prototype = Object.create(Error.prototype, {});
+
+
var load_class = function(class_name, module_name, registry) {
// Tries to load a class
//
// Tries to load a class from a module using require.js, if a module
// is specified, otherwise tries to load a class from the global
// registry, if the global registry is provided.
- return new Promise(function(resolve, reject) {
+ return new rsvp.Promise(function(resolve, reject) {
// Try loading the view module using require.js
if (module_name) {
@@ -638,13 +667,13 @@ define([
var resolve_dict = function(d) {
// Resolve a promiseful dictionary.
- // Returns a single Promise.
+ // Returns a single rsvp.Promise.
var keys = Object.keys(d);
var values = [];
keys.forEach(function(key) {
values.push(d[key]);
});
- return Promise.all(values).then(function(v) {
+ return rsvp.Promise.all(values).then(function(v) {
d = {};
for(var i=0; i