Skip to content

Commit

Permalink
Merge pull request cocos#1396 from jareguo/master
Browse files Browse the repository at this point in the history
improve error message if asset not found
  • Loading branch information
nantas authored Dec 26, 2016
2 parents 64573f8 + adb9437 commit b117e49
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
20 changes: 16 additions & 4 deletions cocos2d/core/load-pipeline/uuid-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ function loadDepends (pipeline, item, asset, tdInfo, deferredLoadRawAssetsInRunt
// cache dependencies for auto release
var dependKeys = item.dependKeys = [];

asset._uuid = uuid;

if (deferredLoadRawAssetsInRuntime) {
objList = [];
propList = [];
Expand Down Expand Up @@ -105,14 +107,13 @@ function loadDepends (pipeline, item, asset, tdInfo, deferredLoadRawAssetsInRunt
}
// fast path
if (depends.length === 0) {
asset._uuid = uuid;
return callback(null, asset);
}

// Predefine content for dependencies usage
item.content = asset;
pipeline.flowInDeps(item, depends, function (errors, items) {
var item;
var item, missingAssetReporter;
for (var src in items.map) {
item = items.map[src];
if (item.uuid && item.content) {
Expand All @@ -128,7 +129,16 @@ function loadDepends (pipeline, item, asset, tdInfo, deferredLoadRawAssetsInRunt
if (item) {
if (item.complete || item.content) {
if (item.error) {
cc._throw(item.error);
if (CC_EDITOR && item.error.errorCode === 'db.NOTFOUND') {
if (!missingAssetReporter) {
var MissingObjectReporter = Editor.require('app://editor/page/scene-utils/missing-object-reporter');
missingAssetReporter = new MissingObjectReporter(asset);
}
missingAssetReporter.stashByOwner(dependObj, dependProp, Editor.serialize.asAsset(dependSrc));
}
else {
cc._throw(item.error);
}
}
else {
var value = item.isRawAsset ? item.url : item.content;
Expand Down Expand Up @@ -159,7 +169,9 @@ function loadDepends (pipeline, item, asset, tdInfo, deferredLoadRawAssetsInRunt
}
}
}
asset._uuid = uuid;
if (CC_EDITOR && missingAssetReporter) {
missingAssetReporter.reportByOwner();
}
callback(null, asset);
});
}
Expand Down
4 changes: 3 additions & 1 deletion cocos2d/core/platform/CCAssetLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ var AssetLibrary = {
}
}
else {
callback(new Error('Can not get asset url by uuid "' + uuid + '", the asset may be deleted.'));
var error = new Error('Can not get asset url by uuid "' + uuid + '", the asset may be deleted.');
error.errorCode = 'db.NOTFOUND';
callback(error);
}
});
}
Expand Down

0 comments on commit b117e49

Please sign in to comment.