diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-09-14 16:02:12 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-09-14 16:02:12 +0100 |
| commit | 011d9a680b42df959a6773cd8609f25bc286f4e0 (patch) | |
| tree | ca4fc678d7caf897d2de3e6905f79bba11d49013 /src | |
| parent | 130b5dc1d918194ceec756d2388c33665efcc169 (diff) | |
Throw an exception rather than crashing if an asset is not found.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cpl.cc | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -109,6 +109,9 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass try { pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, p->id); + if (!asset.second) { + throw DCPReadError (String::compose ("could not find asset %1", p->id.substr (9))); + } picture.reset (new MonoPictureAsset (asset.first, asset.second->chunks.front()->path)); @@ -129,6 +132,9 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass } else { try { pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, p->id); + if (!asset.second) { + throw DCPReadError (String::compose ("could not find asset %1", p->id.substr (9))); + } picture.reset (new StereoPictureAsset (asset.first, asset.second->chunks.front()->path)); @@ -153,6 +159,9 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass try { pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, (*i)->asset_list->main_sound->id); + if (!asset.second) { + throw DCPReadError (String::compose ("could not find asset %1", p->id.substr (9))); + } sound.reset (new SoundAsset (asset.first, asset.second->chunks.front()->path)); shared_ptr<parse::MainSound> s = (*i)->asset_list->main_sound; @@ -174,6 +183,9 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass if ((*i)->asset_list->main_subtitle) { pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, (*i)->asset_list->main_subtitle->id); + if (!asset.second) { + throw DCPReadError (String::compose ("could not find asset %1", p->id.substr (9))); + } subtitle.reset (new SubtitleAsset (asset.first, asset.second->chunks.front()->path)); |
