]> git.sesse.net Git - casparcg/blob - common/exception/exceptions.h
Read/Write data files in UTF-8, characters logged are replaced by ? if non-ascii...
[casparcg] / common / exception / exceptions.h
1 /*\r
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 * This file is part of CasparCG (www.casparcg.com).\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 * Author: Robert Nagy, ronag89@gmail.com\r
20 */\r
21 \r
22 #pragma once\r
23 \r
24 #include <exception>\r
25 #include <boost/exception/all.hpp>\r
26 #include <boost/exception/error_info.hpp>\r
27 #include <boost/throw_exception.hpp>\r
28 \r
29 namespace caspar {\r
30 \r
31 typedef boost::error_info<struct tag_arg_name_info, std::string>                arg_name_info;\r
32 typedef boost::error_info<struct tag_arg_value_info, std::string>               arg_value_info;\r
33 typedef boost::error_info<struct tag_msg_info, std::string>                             msg_info;\r
34 typedef boost::error_info<struct tag_errorstr, std::string>                             errorstr;\r
35 typedef boost::error_info<struct tag_source_info, std::string>                  source_info;\r
36 typedef boost::error_info<struct tag_line_info, size_t>                                 line_info;\r
37 typedef boost::error_info<struct errinfo_nested_exception_, std::exception_ptr> errinfo_nested_exception;\r
38 \r
39 struct caspar_exception                 : virtual boost::exception, virtual std::exception \r
40 {\r
41         caspar_exception(){}\r
42         explicit caspar_exception(const char* msg) : std::exception(msg) {}\r
43 };\r
44 \r
45 struct io_error                                 : virtual caspar_exception {};\r
46 struct directory_not_found              : virtual io_error {};\r
47 struct file_not_found                   : virtual io_error {};\r
48 struct file_read_error          : virtual io_error {};\r
49 \r
50 struct invalid_argument                 : virtual caspar_exception {};\r
51 struct null_argument                    : virtual invalid_argument {};\r
52 struct out_of_range                             : virtual invalid_argument {};\r
53 struct bad_alloc                                : virtual caspar_exception {};\r
54 \r
55 struct invalid_operation                : virtual caspar_exception {};\r
56 struct operation_failed                 : virtual caspar_exception {};\r
57 struct timed_out                                : virtual caspar_exception {};\r
58 \r
59 struct not_supported                    : virtual caspar_exception {};\r
60 struct not_implemented                  : virtual caspar_exception {};\r
61 \r
62 }\r
63 \r
64 namespace std\r
65 {\r
66 \r
67 inline bool operator!=(const std::exception_ptr& lhs, const std::exception_ptr& rhs)\r
68 {\r
69         return !(lhs == rhs);\r
70 }\r
71 \r
72 inline bool operator!=(const std::exception_ptr& lhs, std::nullptr_t)\r
73 {\r
74         return !(lhs == nullptr);\r
75 }\r
76 \r
77 inline bool operator!=(std::nullptr_t, const std::exception_ptr& rhs)\r
78 {\r
79         return !(nullptr == rhs);\r
80 }\r
81 \r
82 }