2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
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.
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.
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.
20 /** @file src/exceptions.h
21 * @brief Our exceptions.
28 /** @class StringError
29 * @brief A parent class for exceptions using messages held in a std::string
31 class StringError : public std::exception
34 /** @param w Error message */
35 StringError (std::string w) {
39 virtual ~StringError () throw () {}
41 /** @return error message */
42 char const * what () const throw () {
43 return _what.c_str ();
51 /** @class DecodeError
52 * @brief A low-level problem with the decoder (possibly due to the nature
55 class DecodeError : public StringError
58 DecodeError (std::string s)
63 /** @class EncodeError
64 * @brief A low-level problem with an encoder.
66 class EncodeError : public StringError
69 EncodeError (std::string s)
75 * @brief Parent class for file-related errors.
77 class FileError : public StringError
80 FileError (std::string m, std::string f)
85 virtual ~FileError () throw () {}
87 std::string file () const {
96 /** @class OpenFileError.
97 * @brief Indicates that some error occurred when trying to open a file.
99 class OpenFileError : public FileError
102 /** @param f File that we were trying to open */
103 OpenFileError (std::string f)
104 : FileError ("could not open file " + f, f)
108 /** @class CreateFileError.
109 * @brief Indicates that some error occurred when trying to create a file.
111 class CreateFileError : public FileError
114 /** @param f File that we were trying to create */
115 CreateFileError (std::string f)
116 : FileError ("could not create file " + f, f)
120 /** @class WriteFileError.
121 * @brief Indicates that some error occurred when trying to write to a file
123 class WriteFileError : public FileError
126 /** @param f File that we were trying to write to.
127 * @param e errno value, or 0.
129 WriteFileError (std::string f, int e)
133 s << "could not write to file " << f;
135 s << " (" << strerror (e) << ")";
141 /** @class SettingError.
142 * @brief Indicates that something is wrong with a setting.
144 class SettingError : public StringError
147 /** @param s Name of setting that was required.
150 SettingError (std::string s, std::string m)
155 virtual ~SettingError () throw () {}
157 /** @return name of setting in question */
158 std::string setting () const {
163 std::string _setting;
166 /** @class MissingSettingError.
167 * @brief Indicates that a Film is missing a setting that is required for some operation.
169 class MissingSettingError : public SettingError
172 /** @param s Name of setting that was required */
173 MissingSettingError (std::string s)
174 : SettingError (s, "missing required setting " + s)
178 /** @class BadSettingError
179 * @brief Indicates that a setting is bad in some way.
181 class BadSettingError : public SettingError
184 /** @param s Name of setting that is bad */
185 BadSettingError (std::string s, std::string m)
186 : SettingError (s, m)
190 /** @class NetworkError.
191 * @brief Indicates some problem with communication on the network.
193 class NetworkError : public StringError
196 NetworkError (std::string s)
201 class PlayError : public StringError
204 PlayError (std::string s)
209 class DVDError : public StringError
212 DVDError (std::string s)