]> git.sesse.net Git - casparcg/blob - common/exception/exceptions.h
2.0.2: Changed NTSC square-pixels dimensions.
[casparcg] / common / exception / exceptions.h
1 /*\r
2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 *  This file is part of CasparCG.\r
5 *\r
6 *    CasparCG is free software: you can redistribute it and/or modify\r
7 *    it under the terms of the GNU General Public License as published by\r
8 *    the Free Software Foundation, either version 3 of the License, or\r
9 *    (at your option) any later version.\r
10 *\r
11 *    CasparCG is distributed in the hope that it will be useful,\r
12 *    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 *    GNU General Public License for more details.\r
15 \r
16 *    You should have received a copy of the GNU General Public License\r
17 *    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 */\r
20 #pragma once\r
21 \r
22 #include <exception>\r
23 #include <boost/exception/all.hpp>\r
24 #include <boost/exception/error_info.hpp>\r
25 #include <boost/throw_exception.hpp>\r
26 \r
27 namespace caspar {\r
28 \r
29 typedef boost::error_info<struct tag_arg_name_info, std::string>                arg_name_info;\r
30 typedef boost::error_info<struct tag_arg_value_info, std::string>               arg_value_info;\r
31 typedef boost::error_info<struct tag_msg_info, std::string>                             msg_info;\r
32 typedef boost::error_info<struct tag_errorstr, std::string>                             errorstr;\r
33 typedef boost::error_info<struct tag_source_info, std::string>                  source_info;\r
34 typedef boost::error_info<struct tag_line_info, size_t>                                 line_info;\r
35 typedef boost::error_info<struct errinfo_nested_exception_, std::exception_ptr> errinfo_nested_exception;\r
36 \r
37 struct caspar_exception                 : virtual boost::exception, virtual std::exception \r
38 {\r
39         caspar_exception(){}\r
40         explicit caspar_exception(const char* msg) : std::exception(msg) {}\r
41 };\r
42 \r
43 struct io_error                                 : virtual caspar_exception {};\r
44 struct directory_not_found              : virtual io_error {};\r
45 struct file_not_found                   : virtual io_error {};\r
46 struct file_read_error          : virtual io_error {};\r
47 \r
48 struct invalid_argument                 : virtual caspar_exception {};\r
49 struct null_argument                    : virtual invalid_argument {};\r
50 struct out_of_range                             : virtual invalid_argument {};\r
51 struct bad_alloc                                : virtual caspar_exception {};\r
52 \r
53 struct invalid_operation                : virtual caspar_exception {};\r
54 struct operation_failed                 : virtual caspar_exception {};\r
55 \r
56 struct not_supported                    : virtual caspar_exception {};\r
57 struct not_implemented                  : virtual caspar_exception {};\r
58 \r
59 }\r
60 \r
61 namespace std\r
62 {\r
63 \r
64 inline bool operator!=(const std::exception_ptr& lhs, const std::exception_ptr& rhs)\r
65 {\r
66         return !(lhs == rhs);\r
67 }\r
68 \r
69 inline bool operator!=(const std::exception_ptr& lhs, std::nullptr_t)\r
70 {\r
71         return !(lhs == nullptr);\r
72 }\r
73 \r
74 inline bool operator!=(std::nullptr_t, const std::exception_ptr& rhs)\r
75 {\r
76         return !(nullptr == rhs);\r
77 }\r
78 \r
79 }