New test.
[libsub.git] / src / exceptions.h
1 /*
2     Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef LIBSUB_EXCEPTIONS_H
21 #define LIBSUB_EXCEPTIONS_H
22
23 #include <stdexcept>
24 #include <string>
25 #include <list>
26
27 namespace sub {
28
29 /** @class XMLError
30  *  @brief An error raised when reading an XML file.
31  */
32 class XMLError : public std::runtime_error
33 {
34 public:
35         XMLError (std::string const & message)
36                 : std::runtime_error (message)
37         {}
38 };
39
40 /** @class STLError
41  *  @brief An error raised when reading a binary STL file.
42  */
43 class STLError : public std::runtime_error
44 {
45 public:
46         STLError (std::string const & message)
47                 : std::runtime_error (message)
48         {}
49 };
50
51 /** @class SubripError
52  *  @brief An error raised when reading a Subrip file.
53  */
54 class SubripError : public std::runtime_error
55 {
56 public:
57         SubripError (std::string saw, std::string expecting, std::list<std::string> context);
58         ~SubripError () throw () {}
59
60         std::list<std::string> context () const {
61                 return _context;
62         }
63
64 private:
65         std::list<std::string> _context;
66 };
67
68 class SSAError : public std::runtime_error
69 {
70 public:
71         SSAError (std::string message)
72                 : std::runtime_error(message)
73         {}
74 };
75
76 class MXFError : public std::runtime_error
77 {
78 public:
79         MXFError (std::string const & message)
80                 : std::runtime_error (message)
81         {}
82 };
83
84 class UnknownFrameRateError : public std::runtime_error
85 {
86 public:
87         UnknownFrameRateError ()
88                 : std::runtime_error ("unknown frame rate")
89         {}
90 };
91
92 class DCPError : public std::runtime_error
93 {
94 public:
95         DCPError (std::string const & message)
96                 : std::runtime_error (message)
97         {}
98 };
99
100 class ProgrammingError : public std::runtime_error
101 {
102 public:
103         ProgrammingError (std::string file, int line);
104 };
105
106 }
107
108 #endif