Improve an error message.
authorCarl Hetherington <cth@carlh.net>
Thu, 1 Jun 2017 22:46:11 +0000 (23:46 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 1 Jun 2017 22:46:11 +0000 (23:46 +0100)
src/lib/exceptions.cc
src/lib/exceptions.h
src/lib/reel_writer.cc

index cf3708896cbc12ed9ce15a8ca6a938925607c9c7..4e1e1ade3b8e5a1b9da47aa7cb1523ac67472b56 100644 (file)
@@ -81,8 +81,8 @@ InvalidSignerError::InvalidSignerError (string reason)
 
 }
 
-ProgrammingError::ProgrammingError (string file, int line)
-       : runtime_error (String::compose (_("Programming error at %1:%2"), file, line))
+ProgrammingError::ProgrammingError (string file, int line, string message)
+       : runtime_error (String::compose (_("Programming error at %1:%2 %3"), file, line, message))
 {
 
 }
index c1b1aef4b0a61a11ef36ffbae4d928e59cda5f03..08cbcb1d66bf6a593be12c84af52fd2479b5816b 100644 (file)
@@ -233,7 +233,7 @@ public:
 class ProgrammingError : public std::runtime_error
 {
 public:
-       ProgrammingError (std::string file, int line);
+       ProgrammingError (std::string file, int line, std::string message = "");
 };
 
 class TextEncodingError : public std::runtime_error
index 2c74d66bdb664fb2ee4950fd07204349ace269e6..27f10d1ed4bc874f492428522569a470183d14ae 100644 (file)
@@ -361,7 +361,12 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr
        LOG_GENERAL ("create_reel for %1-%2; %3 of %4", _period.from.get(), _period.to.get(), _reel_index, _reel_count);
 
        DCPOMATIC_ASSERT (reel_picture_asset);
-       DCPOMATIC_ASSERT (reel_picture_asset->duration() == _period.duration().frames_round (_film->video_frame_rate ()));
+       if (reel_picture_asset->duration() != _period.duration().frames_round (_film->video_frame_rate ())) {
+               throw ProgrammingError (
+                       __FILE__, __LINE__,
+                       String::compose ("%1 vs %2", reel_picture_asset->duration(), _period.duration().frames_round (_film->video_frame_rate ()))
+                       );
+       }
        reel->add (reel_picture_asset);
 
        /* If we have a hash for this asset in the CPL, assume that it is correct */