Fix build.
[libdcp.git] / src / exceptions.h
1 /*
2     Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
3
4     This file is part of libdcp.
5
6     libdcp is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     libdcp is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
18
19     In addition, as a special exception, the copyright holders give
20     permission to link the code of portions of this program with the
21     OpenSSL library under certain conditions as described in each
22     individual source file, and distribute linked combinations
23     including the two.
24
25     You must obey the GNU General Public License in all respects
26     for all of the code used other than OpenSSL.  If you modify
27     file(s) with this exception, you may extend this exception to your
28     version of the file(s), but you are not obligated to do so.  If you
29     do not wish to do so, delete this exception statement from your
30     version.  If you delete this exception statement from all source
31     files in the program, then also delete it here.
32 */
33
34 #ifndef LIBDCP_EXCEPTIONS_H
35 #define LIBDCP_EXCEPTIONS_H
36
37 #include <boost/filesystem.hpp>
38
39 /** @file  src/exceptions.h
40  *  @brief Exceptions thrown by libdcp.
41  */
42
43 namespace dcp
44 {
45
46 /** @class FileError
47  *  @brief An exception related to a file
48  */
49 class FileError : public std::runtime_error
50 {
51 public:
52         FileError (std::string message, boost::filesystem::path filename, int number);
53         ~FileError () throw () {}
54
55         /** @return filename of file that was involved */
56         boost::filesystem::path filename () const {
57                 return _filename;
58         }
59
60         /** @return error number of the error */
61         int number () const {
62                 return _number;
63         }
64
65 private:
66         /** filename of file that was involved */
67         boost::filesystem::path _filename;
68         int _number;
69 };
70
71 /** @class MXFFileError
72  *  @brief An exception related to an MXF file
73  */
74 class MXFFileError : public FileError
75 {
76 public:
77         MXFFileError (std::string message, boost::filesystem::path filename, int number)
78                 : FileError (message, filename, number)
79         {}
80 };
81
82 /** @class MiscError
83  *  @brief A miscellaneous exception
84  */
85 class MiscError : public std::runtime_error
86 {
87 public:
88         explicit MiscError (std::string message)
89                 : std::runtime_error (message)
90         {}
91 };
92
93 /** @class DCPReadError
94  *  @brief A DCP read exception
95  */
96 class DCPReadError : public std::runtime_error
97 {
98 public:
99         explicit DCPReadError (std::string message)
100                 : std::runtime_error (message)
101         {}
102 };
103
104 /** @class MissingAssetError
105  *  @brief An error of a missing asset.
106  */
107 class MissingAssetError : public DCPReadError
108 {
109 public:
110         enum AssetType {
111                 MAIN_PICTURE,  //< main picture is missing
112                 MAIN_SOUND,    //< main sound is missing
113                 MAIN_SUBTITLE, //< main subtitle is missing
114                 UNKNOWN        //< something is missing but we don't know what
115         };
116
117         MissingAssetError (boost::filesystem::path, AssetType = UNKNOWN);
118         ~MissingAssetError () throw () {}
119 };
120
121 /** @class XMLError
122  *  @brief An XML error
123  */
124 class XMLError : public std::runtime_error
125 {
126 public:
127         explicit XMLError (std::string message)
128                 : std::runtime_error (message)
129         {}
130 };
131
132 /** @class UnresolvedRefError
133  *  @brief An exception caused by a reference (by UUID) to something which is not known
134  */
135 class UnresolvedRefError : public std::runtime_error
136 {
137 public:
138         explicit UnresolvedRefError (std::string id);
139 };
140
141 /** @class TimeFormatError
142  *  @brief A an error with a string passed to LocalTime.
143  */
144 class TimeFormatError : public std::runtime_error
145 {
146 public:
147         explicit TimeFormatError (std::string bad_time);
148 };
149
150 /** @class NotEncryptedError
151  *  @brief An error raised when creating a DecryptedKDM object for assets that are not
152  *  encrypted.
153  */
154 class NotEncryptedError : public std::runtime_error
155 {
156 public:
157         explicit NotEncryptedError (std::string const & what);
158         ~NotEncryptedError () throw () {}
159 };
160
161 /** @class ProgrammingError
162  *  @brief An exception thrown when a DCP_ASSERT fails; something that should not happen.
163  */
164 class ProgrammingError : public std::runtime_error
165 {
166 public:
167         ProgrammingError (std::string file, int line);
168 };
169
170 class MismatchedStandardError : public DCPReadError
171 {
172 public:
173         MismatchedStandardError ();
174 };
175
176 class KDMDecryptionError : public std::runtime_error
177 {
178 public:
179         KDMDecryptionError (std::string message);
180 };
181
182 }
183
184 #endif