CARLA
 
载入中...
搜索中...
未找到
Exception.cpp
浏览该文件的文档.
1// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#include "carla/Exception.h" // 引入Carla异常处理头文件
8#include <boost/assert/source_location.hpp> // 引入Boost的源位置头文件
9
10// =============================================================================
11// -- 定义boost::throw_exception --------------------------------------------
12// =============================================================================
13
14#ifdef BOOST_NO_EXCEPTIONS // 如果禁用异常
15
16namespace boost { // 在boost命名空间中
17
18 void throw_exception(const std::exception &e) { // 定义抛出异常函数
19 carla::throw_exception(e); // 调用Carla的抛出异常函数
20 }
21
22 void throw_exception( // 重载的抛出异常函数,带有源位置信息
23 const std::exception &e,
24 boost::source_location const & loc) { // 接受异常和源位置
25 throw_exception(e); // 调用上面定义的抛出异常函数
26 }
27
28} // namespace boost
29
30#endif // BOOST_NO_EXCEPTIONS
31
32// =============================================================================
33// -- 处理与rpclib捆绑的Boost.Asio的临时解决方案----------------------------
34// =============================================================================
35
36#ifdef ASIO_NO_EXCEPTIONS
37
38#include <exception> // 引入异常头文件
39#include <system_error> // 引入系统错误头文件
40#include <typeinfo> // 引入类型信息头文件
41
42namespace clmdep_asio { // 在clmdep_asio命名空间中
43namespace detail { // 在detail子命名空间中
44
45 template <typename Exception> // 定义模板函数,接受任意异常类型
46 void throw_exception(const Exception& e) { // 抛出异常函数
47 carla::throw_exception(e); // 调用Carla的抛出异常函数
48 }
49
50 template void throw_exception<std::bad_cast>(const std::bad_cast &);
51 template void throw_exception<std::exception>(const std::exception &);
52 template void throw_exception<std::system_error>(const std::system_error &);
53
54} // namespace detail
55} // namespace clmdep_asio
56#endif // ASIO_NO_EXCEPTIONS
void throw_exception(const std::exception &e)
Definition Carla.cpp:142