summaryrefslogtreecommitdiff
path: root/src/exceptions.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-01-08 10:05:49 +0000
committerCarl Hetherington <cth@carlh.net>2014-01-08 10:05:49 +0000
commit83591a4390db550a7d1495b9699c62315e2d7710 (patch)
tree29c93f38853ae2d99c7bca8c7b52d2c294881c0e /src/exceptions.h
parent3a148fab61d2b23379589a4f0f256c21950742b8 (diff)
Throw better file errors (with numbers).
Diffstat (limited to 'src/exceptions.h')
-rw-r--r--src/exceptions.h16
1 files changed, 12 insertions, 4 deletions
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)
{}
};