boost::throw_exception 简单的测试程序

使用boost::throw_exception进行异常处理
128 篇文章 ¥59.90 ¥99.00
这篇博客介绍了一个简单的测试程序,展示了如何利用Boost库中的boost::throw_exception函数抛出自定义异常。文中定义了一个继承自std::exception的自定义异常类型,并在主函数中通过该函数抛出异常,同时携带文件名和行号等附加信息。异常被捕获后,通过打印异常详情来展示boost::throw_exception在异常处理中的应用。

boost::throw_exception 简单的测试程序

boost::throw_exception 是 Boost 库中的一个异常抛出函数,它可以用于在 C++ 程序中抛出异常。本文将展示一个简单的测试程序,演示如何使用 boost::throw_exception 函数。

#include <iostream>
#include <boost/exception/all.hpp>

// 自定义异常类型
struct my_exception : <
try to start node0 try to start node1 try to start node2 try to start node3 Exceed waiting time. Please try again to start node3 Exceed waiting time. Please try again to start node0 Exceed waiting time. Please try again to start node1 Exceed waiting time. Please try again to start node2 [INITIALIZER][Initializer]Init failed,EINFO=/FISCO-BCOS/libinitializer/LedgerInitializer.cpp(136): Throw in function vector<dev::GROUP_ID> dev::initializer::LedgerInitializer::initLedgers() Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::exception> > std::exception::what: std::exception Init failed!!! config file path : config.ini [2025-03-30 09:33:35] Initializing... [INITIALIZER][LedgerInitializer]initLedger failed,errorInfo=/FISCO-BCOS/libstorage/SQLConnectionPool.cpp(131): Throw in function void dev::storage::errorExitOut(std::stringstream &) Dynamic exception type: boost::exception_detail::clone_impl<dev::storage::StorageException> std::exception::what: init connection pool failed url:127.0.0.1:3306 error msg:Failed to start connection pool -- Access denied for user 'rootroot'@'172.19.0.1' (using password: YES) [INITIALIZER][LedgerInitializer]initLedger failed,EINFO=/FISCO-BCOS/libinitializer/LedgerInitializer.cpp(126): Throw in function auto dev::initializer::LedgerInitializer::initLedgers()::(anonymous class)::operator()(const dev::GROUP_ID &, const std::__cxx11::string &) const Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::exception> > std::exception::what: std::exception [INITIALIZER][Initializer]Init failed,EINFO=/FISCO-BCOS/libinitializer/LedgerInitializer.cpp(136): Throw in function vector<dev::GROUP_ID> dev::initializer::LedgerInitializer::initLedgers() Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::exception> > std::exception::what: std::exception Init failed!!! [INIT
最新发布
03-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值