Commit 7b75d15d authored by Adam Barth's avatar Adam Barth

Improve error message for non-existent asset

Now we print the name of the asset and the base directory where we looked for
the error instead of throwing a null pointer exception.

Fixes #296
parent b065036a
...@@ -31,7 +31,7 @@ class _Asset { ...@@ -31,7 +31,7 @@ class _Asset {
Iterable<_Asset> _parseAssets(Map manifestDescriptor, String manifestPath) sync* { Iterable<_Asset> _parseAssets(Map manifestDescriptor, String manifestPath) sync* {
if (manifestDescriptor == null || !manifestDescriptor.containsKey('assets')) if (manifestDescriptor == null || !manifestDescriptor.containsKey('assets'))
return; return;
String basePath = new File(manifestPath).parent.path; String basePath = path.dirname(path.absolute(manifestPath));
for (String asset in manifestDescriptor['assets']) for (String asset in manifestDescriptor['assets'])
yield new _Asset(base: basePath, key: asset); yield new _Asset(base: basePath, key: asset);
} }
...@@ -198,8 +198,14 @@ class BuildCommand extends FlutterCommand { ...@@ -198,8 +198,14 @@ class BuildCommand extends FlutterCommand {
archive.addFile(_createSnapshotFile(snapshotPath)); archive.addFile(_createSnapshotFile(snapshotPath));
} }
for (_Asset asset in assets) for (_Asset asset in assets) {
archive.addFile(_createFile(asset.key, asset.base)); ArchiveFile file = _createFile(asset.key, asset.base);
if (file == null) {
stderr.writeln('Cannot find asset "${asset.key}" in directory "${path.absolute(asset.base)}".');
return 1;
}
archive.addFile(file);
}
for (_MaterialAsset asset in materialAssets) { for (_MaterialAsset asset in materialAssets) {
ArchiveFile file = _createFile(asset.key, assetBase); ArchiveFile file = _createFile(asset.key, assetBase);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment