libsub
exceptions.h
1 /*
2  Copyright (C) 2014-2021 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 <list>
24 #include <stdexcept>
25 #include <string>
26 #include <vector>
27 
28 namespace sub {
29 
33 class XMLError : public std::runtime_error
34 {
35 public:
36  XMLError (std::string const & message)
37  : std::runtime_error (message)
38  {}
39 };
40 
44 class STLError : public std::runtime_error
45 {
46 public:
47  STLError (std::string const & message)
48  : std::runtime_error (message)
49  {}
50 };
51 
55 class SubripError : public std::runtime_error
56 {
57 public:
58  SubripError (std::string saw, std::string expecting, std::list<std::string> context);
59  ~SubripError () throw () {}
60 
61  std::list<std::string> context () const {
62  return _context;
63  }
64 
65 private:
66  std::list<std::string> _context;
67 };
68 
69 
73 class WebVTTError : public std::runtime_error
74 {
75 public:
76  WebVTTError(std::string message)
77  : std::runtime_error(message.c_str())
78  {}
79 
80  WebVTTError(std::string saw, std::string expecting, std::list<std::string> context);
81 
82  ~WebVTTError() throw () {}
83 
84  std::list<std::string> context() const {
85  return _context;
86  }
87 
88 private:
89  std::list<std::string> _context;
90 };
91 
92 
94 {
95 public:
97  : WebVTTError("No WEBVTT header found")
98  {}
99 };
100 
101 
102 class SSAError : public std::runtime_error
103 {
104 public:
105  SSAError (std::string message)
106  : std::runtime_error(message)
107  {}
108 };
109 
110 class MXFError : public std::runtime_error
111 {
112 public:
113  MXFError (std::string const & message)
114  : std::runtime_error (message)
115  {}
116 };
117 
118 class UnknownFrameRateError : public std::runtime_error
119 {
120 public:
122  : std::runtime_error ("unknown frame rate")
123  {}
124 };
125 
126 class ProgrammingError : public std::runtime_error
127 {
128 public:
129  ProgrammingError (std::string file, int line);
130 };
131 
132 }
133 
134 #endif
Definition: exceptions.h:111
Definition: exceptions.h:127
Definition: exceptions.h:103
An error raised when reading a binary STL file.
Definition: exceptions.h:45
An error raised when reading a Subrip file.
Definition: exceptions.h:56
Definition: exceptions.h:119
An error raised when reading a WebVTT file.
Definition: exceptions.h:74
Definition: exceptions.h:94
An error raised when reading an XML file.
Definition: exceptions.h:34