diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-01-08 10:05:49 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-01-08 10:05:49 +0000 |
| commit | 83591a4390db550a7d1495b9699c62315e2d7710 (patch) | |
| tree | 29c93f38853ae2d99c7bca8c7b52d2c294881c0e /src | |
| parent | 3a148fab61d2b23379589a4f0f256c21950742b8 (diff) | |
Throw better file errors (with numbers).
Diffstat (limited to 'src')
| -rw-r--r-- | src/certificates.cc | 3 | ||||
| -rw-r--r-- | src/cpl.cc | 2 | ||||
| -rw-r--r-- | src/dcp.cc | 8 | ||||
| -rw-r--r-- | src/exceptions.h | 16 | ||||
| -rw-r--r-- | src/kdm.cc | 4 | ||||
| -rw-r--r-- | src/mono_picture_asset.cc | 40 | ||||
| -rw-r--r-- | src/mono_picture_asset_writer.cc | 12 | ||||
| -rw-r--r-- | src/mono_picture_frame.cc | 5 | ||||
| -rw-r--r-- | src/picture_asset_writer_common.cc | 19 | ||||
| -rw-r--r-- | src/signer.cc | 2 | ||||
| -rw-r--r-- | src/sound_asset.cc | 36 | ||||
| -rw-r--r-- | src/sound_frame.cc | 5 | ||||
| -rw-r--r-- | src/stereo_picture_asset.cc | 15 | ||||
| -rw-r--r-- | src/stereo_picture_asset_writer.cc | 30 | ||||
| -rw-r--r-- | src/stereo_picture_frame.cc | 5 | ||||
| -rw-r--r-- | src/util.cc | 7 |
16 files changed, 123 insertions, 86 deletions
diff --git a/src/certificates.cc b/src/certificates.cc index aa7972a5..2f5d47fd 100644 --- a/src/certificates.cc +++ b/src/certificates.cc @@ -19,6 +19,7 @@ #include <sstream> #include <vector> +#include <cerrno> #include <boost/algorithm/string.hpp> #include <openssl/x509.h> #include <openssl/ssl.h> @@ -52,7 +53,7 @@ Certificate::Certificate (boost::filesystem::path filename) { FILE* f = fopen_boost (filename, "r"); if (!f) { - throw FileError ("could not open file", filename); + throw FileError ("could not open file", filename, errno); } if (!PEM_read_X509 (f, &_certificate, 0, 0)) { @@ -70,7 +70,7 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass try { cpl.reset (new parse::CPL (file)); } catch (FileError& e) { - boost::throw_exception (FileError ("could not load CPL file", file)); + boost::throw_exception (FileError ("could not load CPL file", file, e.number ())); } /* Now cherry-pick the required bits into our own data structure */ @@ -228,7 +228,7 @@ DCP::read_assets () } } catch (FileError& e) { - boost::throw_exception (FileError ("could not load AssetMap file", _files.asset_map)); + boost::throw_exception (FileError ("could not load AssetMap file", _files.asset_map, e.number ())); } for (list<shared_ptr<libdcp::parse::AssetMapAsset> >::const_iterator i = asset_map->assets.begin(); i != asset_map->assets.end(); ++i) { @@ -266,18 +266,18 @@ DCP::read_assets () } if (_files.cpls.empty ()) { - boost::throw_exception (FileError ("no CPL files found", "")); + boost::throw_exception (DCPReadError ("no CPL files found")); } if (_files.pkl.empty ()) { - boost::throw_exception (FileError ("no PKL file found", "")); + boost::throw_exception (DCPReadError ("no PKL file found")); } shared_ptr<parse::PKL> pkl; try { pkl.reset (new parse::PKL (_files.pkl)); } catch (FileError& e) { - boost::throw_exception (FileError ("could not load PKL file", _files.pkl)); + boost::throw_exception (FileError ("could not load PKL file", _files.pkl, e.number ())); } _asset_maps.push_back (make_pair (boost::filesystem::absolute (_directory).string(), asset_map)); diff --git a/src/exceptions.h b/src/exceptions.h index 0c43c70a..602aa16b 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -21,6 +21,7 @@ #define LIBDCP_EXCEPTIONS_H #include <boost/filesystem.hpp> +#include "compose.hpp" /** @file src/exceptions.h * @brief Exceptions thrown by libdcp. @@ -33,9 +34,10 @@ namespace libdcp class FileError : public std::exception { public: - FileError (std::string const & message, boost::filesystem::path filename) - : _message (message + " (" + filename.string() + ")") + FileError (std::string const & message, boost::filesystem::path filename, int number) + : _message (String::compose ("%1 (error %2) (%3)", message, filename.string(), number)) , _filename (filename) + , _number (number) {} ~FileError () throw () {} @@ -50,19 +52,25 @@ public: return _filename; } + /** @return error number of the error */ + int number () const { + return _number; + } + private: /** message part */ std::string _message; /** filename of file that was involved */ boost::filesystem::path _filename; + int _number; }; /** @brief An exception related to an MXF file */ class MXFFileError : public FileError { public: - MXFFileError (std::string const & message, boost::filesystem::path filename) - : FileError (message, filename) + MXFFileError (std::string const & message, boost::filesystem::path filename, int number) + : FileError (message, filename, number) {} }; @@ -52,13 +52,13 @@ KDM::KDM (boost::filesystem::path kdm, boost::filesystem::path private_key) FILE* private_key_file = fopen_boost (private_key, "r"); if (!private_key_file) { - throw FileError ("could not find RSA private key file", private_key); + throw FileError ("could not find RSA private key file", private_key, errno); } RSA* rsa = PEM_read_RSAPrivateKey (private_key_file, 0, 0, 0); fclose (private_key_file); if (!rsa) { - throw FileError ("could not read RSA private key file", private_key); + throw FileError ("could not read RSA private key file", private_key, errno); } /* Use it to decrypt the keys */ diff --git a/src/mono_picture_asset.cc b/src/mono_picture_asset.cc index 52c87738..8986e1ff 100644 --- a/src/mono_picture_asset.cc +++ b/src/mono_picture_asset.cc @@ -48,8 +48,9 @@ MonoPictureAsset::create (boost::function<boost::filesystem::path (int)> get_pat { ASDCP::JP2K::CodestreamParser j2k_parser; ASDCP::JP2K::FrameBuffer frame_buffer (4 * Kumu::Megabyte); - if (ASDCP_FAILURE (j2k_parser.OpenReadFrame (get_path(0).string().c_str(), frame_buffer))) { - boost::throw_exception (FileError ("could not open JPEG2000 file for reading", get_path (0))); + Kumu::Result_t r = j2k_parser.OpenReadFrame (get_path(0).string().c_str(), frame_buffer); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (FileError ("could not open JPEG2000 file for reading", get_path(0), r)); } ASDCP::JP2K::PictureDescriptor picture_desc; @@ -60,20 +61,23 @@ MonoPictureAsset::create (boost::function<boost::filesystem::path (int)> get_pat fill_writer_info (&writer_info, _uuid, _interop, _metadata); ASDCP::JP2K::MXFWriter mxf_writer; - if (ASDCP_FAILURE (mxf_writer.OpenWrite (path().string().c_str(), writer_info, picture_desc, 16384, false))) { - boost::throw_exception (MXFFileError ("could not open MXF file for writing", path().string())); + r = mxf_writer.OpenWrite (path().string().c_str(), writer_info, picture_desc, 16384, false); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("could not open MXF file for writing", path().string(), r)); } for (int i = 0; i < _intrinsic_duration; ++i) { boost::filesystem::path const path = get_path (i); - if (ASDCP_FAILURE (j2k_parser.OpenReadFrame (path.string().c_str(), frame_buffer))) { - boost::throw_exception (FileError ("could not open JPEG2000 file for reading", path)); + Kumu::Result_t r = j2k_parser.OpenReadFrame (path.string().c_str(), frame_buffer); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (FileError ("could not open JPEG2000 file for reading", path, r)); } - if (ASDCP_FAILURE (mxf_writer.WriteFrame (frame_buffer, _encryption_context, 0))) { - boost::throw_exception (MXFFileError ("error in writing video MXF", this->path().string())); + r = mxf_writer.WriteFrame (frame_buffer, _encryption_context, 0); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("error in writing video MXF", this->path().string(), r)); } if (_progress) { @@ -81,8 +85,9 @@ MonoPictureAsset::create (boost::function<boost::filesystem::path (int)> get_pat } } - if (ASDCP_FAILURE (mxf_writer.Finalize())) { - boost::throw_exception (MXFFileError ("error in finalising video MXF", path().string())); + r = mxf_writer.Finalize(); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("error in finalising video MXF", path().string(), r)); } } @@ -90,8 +95,9 @@ void MonoPictureAsset::read () { ASDCP::JP2K::MXFReader reader; - if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) { - boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string())); + Kumu::Result_t r = reader.OpenRead (path().string().c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r)); } ASDCP::JP2K::PictureDescriptor desc; @@ -126,13 +132,15 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, bo } ASDCP::JP2K::MXFReader reader_A; - if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) { - boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string())); + Kumu::Result_t r = reader_A.OpenRead (path().string().c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r)); } ASDCP::JP2K::MXFReader reader_B; - if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) { - boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string())); + r = reader_B.OpenRead (other->path().string().c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r)); } ASDCP::JP2K::PictureDescriptor desc_A; diff --git a/src/mono_picture_asset_writer.cc b/src/mono_picture_asset_writer.cc index ccbc8e87..6f0ba973 100644 --- a/src/mono_picture_asset_writer.cc +++ b/src/mono_picture_asset_writer.cc @@ -71,7 +71,7 @@ MonoPictureAssetWriter::write (uint8_t* data, int size) string hash; ASDCP::Result_t const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _state->encryption_context, 0, &hash); if (ASDCP_FAILURE (r)) { - boost::throw_exception (MXFFileError ("error in writing video MXF (" + lexical_cast<string> (int(r)) + ")", _asset->path().string())); + boost::throw_exception (MXFFileError ("error in writing video MXF", _asset->path().string(), r)); } ++_frames_written; @@ -84,8 +84,9 @@ MonoPictureAssetWriter::fake_write (int size) assert (_started); assert (!_finalized); - if (ASDCP_FAILURE (_state->mxf_writer.FakeWriteFrame (size))) { - boost::throw_exception (MXFFileError ("error in writing video MXF", _asset->path().string())); + Kumu::Result_t r = _state->mxf_writer.FakeWriteFrame (size); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("error in writing video MXF", _asset->path().string(), r)); } ++_frames_written; @@ -96,8 +97,9 @@ MonoPictureAssetWriter::finalize () { assert (!_finalized); - if (ASDCP_FAILURE (_state->mxf_writer.Finalize())) { - boost::throw_exception (MXFFileError ("error in finalizing video MXF", _asset->path().string())); + Kumu::Result_t r = _state->mxf_writer.Finalize(); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("error in finalizing video MXF", _asset->path().string(), r)); } _finalized = true; diff --git a/src/mono_picture_frame.cc b/src/mono_picture_frame.cc index 04f2efd7..890967d1 100644 --- a/src/mono_picture_frame.cc +++ b/src/mono_picture_frame.cc @@ -41,8 +41,9 @@ using namespace libdcp; MonoPictureFrame::MonoPictureFrame (boost::filesystem::path mxf_path, int n, ASDCP::AESDecContext* c) { ASDCP::JP2K::MXFReader reader; - if (ASDCP_FAILURE (reader.OpenRead (mxf_path.string().c_str()))) { - boost::throw_exception (FileError ("could not open MXF file for reading", mxf_path)); + Kumu::Result_t r = reader.OpenRead (mxf_path.string().c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (FileError ("could not open MXF file for reading", mxf_path, r)); } /* XXX: unfortunate guesswork on this buffer size */ diff --git a/src/picture_asset_writer_common.cc b/src/picture_asset_writer_common.cc index 94999131..99f55be0 100644 --- a/src/picture_asset_writer_common.cc +++ b/src/picture_asset_writer_common.cc @@ -44,15 +44,16 @@ void libdcp::start (PictureAssetWriter* writer, shared_ptr<P> state, Q* asset, u asset->fill_writer_info (&state->writer_info, asset->uuid(), writer->_asset->interop(), writer->_asset->metadata()); - if (ASDCP_FAILURE (state->mxf_writer.OpenWrite ( - asset->path().string().c_str(), - state->writer_info, - state->picture_descriptor, - 16384, - writer->_overwrite) - )) { - - boost::throw_exception (MXFFileError ("could not open MXF file for writing", asset->path().string())); + Kumu::Result_t r = state->mxf_writer.OpenWrite ( + asset->path().string().c_str(), + state->writer_info, + state->picture_descriptor, + 16384, + writer->_overwrite + ); + + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("could not open MXF file for writing", asset->path().string(), r)); } writer->_started = true; diff --git a/src/signer.cc b/src/signer.cc index e144edf3..63da8d8e 100644 --- a/src/signer.cc +++ b/src/signer.cc @@ -99,7 +99,7 @@ Signer::add_signature_value (xmlpp::Node* parent, string ns) const signature_context->signKey = xmlSecCryptoAppKeyLoad (_key.string().c_str(), xmlSecKeyDataFormatPem, 0, 0, 0); if (signature_context->signKey == 0) { - throw FileError ("could not load private key file", _key); + throw FileError ("could not load private key file", _key, 0); } /* XXX: set key name to the file name: is this right? */ diff --git a/src/sound_asset.cc b/src/sound_asset.cc index 91a5b005..7033f6af 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -60,8 +60,9 @@ void SoundAsset::read () { ASDCP::PCM::MXFReader reader; - if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) { - boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string())); + Kumu::Result_t r = reader.OpenRead (path().string().c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r)); } ASDCP::PCM::AudioDescriptor desc; @@ -94,8 +95,10 @@ SoundAsset::create (boost::function<boost::filesystem::path (Channel)> get_path) for (int i = 0; i < _channels; ++i) { pcm_parser_channel[i] = new ASDCP::PCM::WAVParser (); } - if (pcm_parser_channel[0]->OpenRead (get_path(LEFT).string().c_str(), asdcp_edit_rate)) { - boost::throw_exception (FileError ("could not open WAV file for reading", get_path(LEFT))); + + Kumu::Result_t r = pcm_parser_channel[0]->OpenRead (get_path(LEFT).string().c_str(), asdcp_edit_rate); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (FileError ("could not open WAV file for reading", get_path(LEFT), r)); } ASDCP::PCM::AudioDescriptor audio_desc; @@ -130,8 +133,9 @@ SoundAsset::create (boost::function<boost::filesystem::path (Channel)> get_path) boost::filesystem::path const path = get_path (channels[i]); - if (ASDCP_FAILURE (pcm_parser_channel[i]->OpenRead (path.string().c_str(), asdcp_edit_rate))) { - boost::throw_exception (FileError ("could not open WAV file for reading", path)); + Kumu::Result_t r = pcm_parser_channel[i]->OpenRead (path.string().c_str(), asdcp_edit_rate); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (FileError ("could not open WAV file for reading", path, r)); } pcm_parser_channel[i]->FillAudioDescriptor (*audio_desc_channel[i]); @@ -149,8 +153,9 @@ SoundAsset::create (boost::function<boost::filesystem::path (Channel)> get_path) MXFAsset::fill_writer_info (&writer_info, _uuid, _interop, _metadata); ASDCP::PCM::MXFWriter mxf_writer; - if (ASDCP_FAILURE (mxf_writer.OpenWrite (path().string().c_str(), writer_info, audio_desc))) { - boost::throw_exception (FileError ("could not open audio MXF for writing", path().string())); + r = mxf_writer.OpenWrite (path().string().c_str(), writer_info, audio_desc); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (FileError ("could not open audio MXF for writing", path().string(), r)); } for (int i = 0; i < _intrinsic_duration; ++i) { @@ -212,13 +217,15 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::f } ASDCP::PCM::MXFReader reader_A; - if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) { - boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string())); + Kumu::Result_t r = reader_A.OpenRead (path().string().c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r)); } ASDCP::PCM::MXFReader reader_B; - if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) { - boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string())); + r = reader_B.OpenRead (other->path().string().c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r)); } ASDCP::PCM::AudioDescriptor desc_A; @@ -327,8 +334,9 @@ SoundAssetWriter::SoundAssetWriter (SoundAsset* a) _asset->fill_writer_info (&_state->writer_info, _asset->uuid (), _asset->interop(), _asset->metadata()); - if (ASDCP_FAILURE (_state->mxf_writer.OpenWrite (_asset->path().string().c_str(), _state->writer_info, _state->audio_desc))) { - boost::throw_exception (FileError ("could not open audio MXF for writing", _asset->path().string())); + Kumu::Result_t r = _state->mxf_writer.OpenWrite (_asset->path().string().c_str(), _state->writer_info, _state->audio_desc); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (FileError ("could not open audio MXF for writing", _asset->path().string(), r)); } } diff --git a/src/sound_frame.cc b/src/sound_frame.cc index 77f4c7a8..6bc52c1a 100644 --- a/src/sound_frame.cc +++ b/src/sound_frame.cc @@ -28,8 +28,9 @@ using namespace libdcp; SoundFrame::SoundFrame (string mxf_path, int n, ASDCP::AESDecContext* c) { ASDCP::PCM::MXFReader reader; - if (ASDCP_FAILURE (reader.OpenRead (mxf_path.c_str()))) { - boost::throw_exception (FileError ("could not open MXF file for reading", mxf_path)); + Kumu::Result_t r = reader.OpenRead (mxf_path.c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (FileError ("could not open MXF file for reading", mxf_path, r)); } /* XXX: unfortunate guesswork on this buffer size */ diff --git a/src/stereo_picture_asset.cc b/src/stereo_picture_asset.cc index 5e692794..1f2230f7 100644 --- a/src/stereo_picture_asset.cc +++ b/src/stereo_picture_asset.cc @@ -38,13 +38,15 @@ StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, } ASDCP::JP2K::MXFSReader reader_A; - if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) { - boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string())); + Kumu::Result_t r = reader_A.OpenRead (path().string().c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r)); } ASDCP::JP2K::MXFSReader reader_B; - if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) { - boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string())); + r = reader_B.OpenRead (other->path().string().c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r)); } ASDCP::JP2K::PictureDescriptor desc_A; @@ -97,8 +99,9 @@ void StereoPictureAsset::read () { ASDCP::JP2K::MXFSReader reader; - if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) { - boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string())); + Kumu::Result_t r = reader.OpenRead (path().string().c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r)); } ASDCP::JP2K::PictureDescriptor desc; diff --git a/src/stereo_picture_asset_writer.cc b/src/stereo_picture_asset_writer.cc index 19b6812d..81ce7fc0 100644 --- a/src/stereo_picture_asset_writer.cc +++ b/src/stereo_picture_asset_writer.cc @@ -70,16 +70,16 @@ StereoPictureAssetWriter::write (uint8_t* data, int size) uint64_t const before_offset = _state->mxf_writer.Tell (); string hash; - if (ASDCP_FAILURE ( - _state->mxf_writer.WriteFrame ( - _state->frame_buffer, - _next_eye == EYE_LEFT ? ASDCP::JP2K::SP_LEFT : ASDCP::JP2K::SP_RIGHT, - _state->encryption_context, - 0, - &hash) - )) { - - boost::throw_exception (MXFFileError ("error in writing video MXF", _asset->path().string())); + Kumu::Result_t r = _state->mxf_writer.WriteFrame ( + _state->frame_buffer, + _next_eye == EYE_LEFT ? ASDCP::JP2K::SP_LEFT : ASDCP::JP2K::SP_RIGHT, + _state->encryption_context, + 0, + &hash + ); + + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("error in writing video MXF", _asset->path().string(), r)); } _next_eye = _next_eye == EYE_LEFT ? EYE_RIGHT : EYE_LEFT; @@ -94,8 +94,9 @@ StereoPictureAssetWriter::fake_write (int size) assert (_started); assert (!_finalized); - if (ASDCP_FAILURE (_state->mxf_writer.FakeWriteFrame (size))) { - boost::throw_exception (MXFFileError ("error in writing video MXF", _asset->path().string())); + Kumu::Result_t r = _state->mxf_writer.FakeWriteFrame (size); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("error in writing video MXF", _asset->path().string(), r)); } _next_eye = _next_eye == EYE_LEFT ? EYE_RIGHT : EYE_LEFT; @@ -107,8 +108,9 @@ StereoPictureAssetWriter::finalize () { assert (!_finalized); - if (ASDCP_FAILURE (_state->mxf_writer.Finalize())) { - boost::throw_exception (MXFFileError ("error in finalizing video MXF", _asset->path().string())); + Kumu::Result_t r = _state->mxf_writer.Finalize(); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("error in finalizing video MXF", _asset->path().string(), r)); } _finalized = true; diff --git a/src/stereo_picture_frame.cc b/src/stereo_picture_frame.cc index 6af79033..dce1f106 100644 --- a/src/stereo_picture_frame.cc +++ b/src/stereo_picture_frame.cc @@ -41,8 +41,9 @@ using namespace libdcp; StereoPictureFrame::StereoPictureFrame (boost::filesystem::path mxf_path, int n) { ASDCP::JP2K::MXFSReader reader; - if (ASDCP_FAILURE (reader.OpenRead (mxf_path.string().c_str()))) { - boost::throw_exception (FileError ("could not open MXF file for reading", mxf_path)); + Kumu::Result_t r = reader.OpenRead (mxf_path.string().c_str()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (FileError ("could not open MXF file for reading", mxf_path, r)); } /* XXX: unfortunate guesswork on this buffer size */ diff --git a/src/util.cc b/src/util.cc index cb58694a..a668b7fc 100644 --- a/src/util.cc +++ b/src/util.cc @@ -82,8 +82,9 @@ string libdcp::make_digest (string filename, boost::function<void (float)>* progress) { Kumu::FileReader reader; - if (ASDCP_FAILURE (reader.OpenRead (filename.c_str ()))) { - boost::throw_exception (FileError ("could not open file to compute digest", filename)); + Kumu::Result_t r = reader.OpenRead (filename.c_str ()); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (FileError ("could not open file to compute digest", filename, r)); } SHA_CTX sha; @@ -101,7 +102,7 @@ libdcp::make_digest (string filename, boost::function<void (float)>* progress) if (r == Kumu::RESULT_ENDOFFILE) { break; } else if (ASDCP_FAILURE (r)) { - boost::throw_exception (FileError ("could not read file to compute digest", filename)); + boost::throw_exception (FileError ("could not read file to compute digest", filename, r)); } SHA1_Update (&sha, read_buffer.Data(), read); |
