Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Handle exceptions thrown in done handles attached to ProjectManager.getAllFiles #6417

Merged
merged 2 commits into from
Jan 8, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1789,9 +1789,11 @@ define(function (require, exports, module) {
includeWorkingSet = filter;
filter = null;
}


var filteredFilesDeferred = new $.Deferred();

// First gather all files in project proper
return _getAllFilesCache().then(function (result) {
_getAllFilesCache().done(function (result) {
// Add working set entries, if requested
if (includeWorkingSet) {
DocumentManager.getWorkingSet().forEach(function (file) {
Expand All @@ -1806,8 +1808,18 @@ define(function (require, exports, module) {
result = result.filter(filter);
}

return result;
// If a done handler attached to the returned filtered files promise
// throws an exception that isn't handled here then it will leave
// _allFilesCachePromise in an inconsistent state such that no
// additional done handlers will ever be called!
try {
filteredFilesDeferred.resolve(result);
} catch (e) {
console.warn("Unhandled exception in getAllFiles handler: ", e);
}
});

return filteredFilesDeferred.promise();
}

/**
Expand Down