Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4505)

Unified Diff: chrome/browser/resources/bookmark_manager/js/bmm.js

Issue 1059413005: Checking node object before checking its property. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/bookmark_manager/js/main.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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];
« no previous file with comments | « no previous file | chrome/browser/resources/bookmark_manager/js/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698