Index: chrome/browser/resources/bookmark_manager/js/bmm.js |
diff --git a/chrome/browser/resources/bookmark_manager/js/bmm.js b/chrome/browser/resources/bookmark_manager/js/bmm.js |
index 8daf62cd720fded56fefc2f64486966d56809fc3..74be7d4150dc18258262d3d5d72f75f63e83b0f2 100644 |
--- a/chrome/browser/resources/bookmark_manager/js/bmm.js |
+++ b/chrome/browser/resources/bookmark_manager/js/bmm.js |
@@ -41,8 +41,14 @@ cr.define('bmm', function() { |
* @return {!Promise<!Array<!BookmarkTreeNode>>} . |
*/ |
function getSubtreePromise(id, foldersOnly) { |
- return new Promise(function(resolve) { |
- chrome.bookmarkManagerPrivate.getSubtree(id, foldersOnly, resolve); |
+ return new Promise(function(resolve, reject) { |
+ chrome.bookmarkManagerPrivate.getSubtree(id, foldersOnly, function(node) { |
+ if (chrome.runtime.lastError) { |
+ reject(new Error(chrome.runtime.lastError.message)); |
+ return; |
+ } |
+ resolve(node); |
+ }); |
}); |
} |
@@ -55,8 +61,12 @@ cr.define('bmm', function() { |
function loadSubtree(id) { |
if (!loadingPromises[id]) { |
loadingPromises[id] = getSubtreePromise(id, false).then(function(nodes) { |
- delete loadingPromises[id]; |
return nodes && nodes[0]; |
+ }, function(error) { |
+ console.error(error.message); |
+ }); |
+ loadingPromises[id].then(function() { |
+ delete loadingPromises[id]; |
}); |
} |
return loadingPromises[id]; |