Throw better file errors (with numbers).
authorCarl Hetherington <cth@carlh.net>
Wed, 8 Jan 2014 10:05:49 +0000 (10:05 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 8 Jan 2014 10:05:49 +0000 (10:05 +0000)
16 files changed:
src/certificates.cc
src/cpl.cc
src/dcp.cc
src/exceptions.h
src/kdm.cc
src/mono_picture_asset.cc
src/mono_picture_asset_writer.cc
src/mono_picture_frame.cc
src/picture_asset_writer_common.cc
src/signer.cc
src/sound_asset.cc
src/sound_frame.cc
src/stereo_picture_asset.cc
src/stereo_picture_asset_writer.cc
src/stereo_picture_frame.cc
src/util.cc

index aa7972a55411d1ec972040347d76196783fb1a82..2f5d47fd6699f58579a372cc0912169278bd3cbf 100644 (file)
@@ -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)) {
index 29214ca6b4c9f3458a485f837c1e3cd3dcba8184..12fdf1020526702b134ff8bc2990c0a1d7e2e0bc 100644 (file)
@@ -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 */
index eaa88367725049e6c6076a7011559a1aa9bd6dfa..f80726fc9313eb0df386eea03c525a4d8eef355b 100644 (file)
@@ -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));
index 0c43c70a5f6d3afe753fdde6b281097c72607f87..602aa16bd24e25e42d2923fd7637b83a634567d5 100644 (file)
@@ -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)
        {}
 };
        
index 9d40cff746df4408e5781c1602cc8f1aec7b91fe..4132b242a99b9d56ca2a7d9c8d13306237143084 100644 (file)
@@ -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 */
index 52c8773804bcacdf99d5e1b6053049ee4c02c204..8986e1ffa0ebb75f1a3d06118a10f9bcb9fca489 100644 (file)
@@ -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;
index ccbc8e870656b826a07082bbbd3e230a090caf35..6f0ba973044391a479b639fb9a1f1974b0975aa4 100644 (file)
@@ -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;
index 04f2efd7a53842d72811930614b5c6a067f75daa..890967d157a0e90c1182918435f87d6eb2ae471a 100644 (file)
@@ -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 */
index 94999131651175382dc3d5407a55bcad7adb5c86..99f55be06934f983cf5d778ac8be226317c4836d 100644 (file)
@@ -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;
index e144edf342578b07891b234e70f0583385495221..63da8d8e28001a12c34488b9b2a6a8142164aee0 100644 (file)
@@ -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? */
index 91a5b0054bbf3736f60744957587a0b1feac89bf..7033f6af96d536d7a0310457637e758a4117c136 100644 (file)
@@ -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));
        }
 }
 
index 77f4c7a8efa63b975917a252df4037c9b17dd35f..6bc52c1a54f73b84fafcd9b8f073bccbc00c5c16 100644 (file)
@@ -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 */
index 5e6927946b904695ef4a9e5c18a3970967d88deb..1f2230f754fea395d1cbc9e2fc20930a6c16fe61 100644 (file)
@@ -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;
index 19b6812dadb40abfc68c445f085aed1287c36623..81ce7fc04303d97806cf5200e3e31d1e3a7b0728 100644 (file)
@@ -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;
index 6af790336fe0ce9d19dc1ef803a771297b1f4d2d..dce1f106dc57e8cce6584cc94cac8bd566bd62c1 100644 (file)
@@ -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 */
index cb58694ad28875c88e0bfa0ea11fabbbb9d33d87..a668b7fc9a5304d587b0ebeedb6094d8e9cc2e8c 100644 (file)
@@ -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);