From 83591a4390db550a7d1495b9699c62315e2d7710 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 8 Jan 2014 10:05:49 +0000 Subject: Throw better file errors (with numbers). --- src/exceptions.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/exceptions.h') 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 +#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) {} }; -- cgit v1.2.3