using std::list;
using std::cout;
using std::string;
+using std::runtime_error;
using boost::shared_ptr;
void
struct zip_source* source = zip_source_buffer (zip, kdm->c_str(), kdm->length(), 0);
if (!source) {
- throw StringError ("could not create ZIP source");
+ throw runtime_error ("could not create ZIP source");
}
if (zip_add (zip, i.filename(film_name).c_str(), source) == -1) {
- throw StringError ("failed to add KDM to ZIP archive");
+ throw runtime_error ("failed to add KDM to ZIP archive");
}
}
if (zip_close (zip) == -1) {
- throw StringError ("failed to close ZIP archive");
+ throw runtime_error ("failed to close ZIP archive");
}
}
#include "i18n.h"
using std::string;
+using std::runtime_error;
/** @param f File that we were trying to open */
OpenFileError::OpenFileError (boost::filesystem::path f)
}
PixelFormatError::PixelFormatError (string o, AVPixelFormat f)
- : StringError (String::compose (_("Cannot handle pixel format %1 during %2"), f, o))
+ : runtime_error (String::compose (_("Cannot handle pixel format %1 during %2"), f, o))
{
}
}
InvalidSignerError::InvalidSignerError ()
- : StringError (_("The certificate chain for signing is invalid"))
+ : runtime_error (_("The certificate chain for signing is invalid"))
{
}
ProgrammingError::ProgrammingError (string file, int line)
- : StringError (String::compose (_("Programming error at %1:%2"), file, line))
+ : runtime_error (String::compose (_("Programming error at %1:%2"), file, line))
{
}
#include <stdexcept>
#include <cstring>
-/** @class StringError
- * @brief A parent class for exceptions using messages held in a std::string
- */
-class StringError : public std::exception
-{
-public:
- /** @param w Error message */
- StringError (std::string w)
- : _what (w)
- {}
-
- virtual ~StringError () throw () {}
-
- /** @return error message */
- char const * what () const throw () {
- return _what.c_str ();
- }
-
-protected:
- /** error message */
- std::string _what;
-};
-
/** @class DecodeError
* @brief A low-level problem with the decoder (possibly due to the nature
* of a source file).
*/
-class DecodeError : public StringError
+class DecodeError : public std::runtime_error
{
public:
DecodeError (std::string s)
- : StringError (s)
+ : std::runtime_error (s)
{}
};
/** @class EncodeError
* @brief A low-level problem with an encoder.
*/
-class EncodeError : public StringError
+class EncodeError : public std::runtime_error
{
public:
EncodeError (std::string s)
- : StringError (s)
+ : std::runtime_error (s)
{}
};
/** @class FileError.
* @brief Parent class for file-related errors.
*/
-class FileError : public StringError
+class FileError : public std::runtime_error
{
public:
/** @param m Error message.
* @param f Name of the file that this exception concerns.
*/
FileError (std::string m, boost::filesystem::path f)
- : StringError (m)
+ : std::runtime_error (m)
, _file (f)
{}
boost::filesystem::path _file;
};
-class JoinError : public StringError
+class JoinError : public std::runtime_error
{
public:
JoinError (std::string s)
- : StringError (s)
+ : std::runtime_error (s)
{}
};
/** @class SettingError.
* @brief Indicates that something is wrong with a setting.
*/
-class SettingError : public StringError
+class SettingError : public std::runtime_error
{
public:
/** @param s Name of setting that was required.
* @param m Message.
*/
SettingError (std::string s, std::string m)
- : StringError (m)
+ : std::runtime_error (m)
, _setting (s)
{}
/** @class NetworkError
* @brief Indicates some problem with communication on the network.
*/
-class NetworkError : public StringError
+class NetworkError : public std::runtime_error
{
public:
NetworkError (std::string s)
- : StringError (s)
+ : std::runtime_error (s)
{}
};
/** @class KDMError
* @brief A problem with a KDM.
*/
-class KDMError : public StringError
+class KDMError : public std::runtime_error
{
public:
KDMError (std::string s)
- : StringError (s)
+ : std::runtime_error (s)
{}
};
/** @class PixelFormatError
* @brief A problem with an unsupported pixel format.
*/
-class PixelFormatError : public StringError
+class PixelFormatError : public std::runtime_error
{
public:
PixelFormatError (std::string o, AVPixelFormat f);
SubRipError (std::string, std::string, boost::filesystem::path);
};
-class DCPError : public StringError
+class DCPError : public std::runtime_error
{
public:
DCPError (std::string s)
- : StringError (s)
+ : std::runtime_error (s)
{}
};
-class InvalidSignerError : public StringError
+class InvalidSignerError : public std::runtime_error
{
public:
InvalidSignerError ();
};
-class ProgrammingError : public StringError
+class ProgrammingError : public std::runtime_error
{
public:
ProgrammingError (std::string file, int line);
};
-class TextEncodingError : public StringError
+class TextEncodingError : public std::runtime_error
{
public:
TextEncodingError (std::string s)
- : StringError (s)
+ : std::runtime_error (s)
{}
};
using std::cout;
using std::list;
using std::set;
+using std::runtime_error;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
}
if (content().empty()) {
- throw StringError (_("You must add some content to the DCP before creating it"));
+ throw runtime_error (_("You must add some content to the DCP before creating it"));
}
if (dcp_content_type() == 0) {
Film::read_metadata ()
{
if (boost::filesystem::exists (file ("metadata")) && !boost::filesystem::exists (file ("metadata.xml"))) {
- throw StringError (_("This film was created with an older version of DCP-o-matic, and unfortunately it cannot be loaded into this version. You will need to create a new Film, re-add your content and set it up again. Sorry!"));
+ throw runtime_error (_("This film was created with an older version of DCP-o-matic, and unfortunately it cannot be loaded into this version. You will need to create a new Film, re-add your content and set it up again. Sorry!"));
}
cxml::Document f ("Metadata");
_state_version = f.number_child<int> ("Version");
if (_state_version > current_state_version) {
- throw StringError (_("This film was created with a newer version of DCP-o-matic, and it cannot be loaded into this version. Sorry!"));
+ throw runtime_error (_("This film was created with a newer version of DCP-o-matic, and it cannot be loaded into this version. Sorry!"));
}
_name = f.string_child ("Name");