From b7013f1be9a5f09ecae4b37f0986352abfcd0dc1 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 22 Feb 2009 07:20:56 +0000 Subject: replaced regular throws with AnytunError::thowErr --- src/bsd/tunDevice.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/bsd') diff --git a/src/bsd/tunDevice.cpp b/src/bsd/tunDevice.cpp index 05b59f1..eee78ca 100644 --- a/src/bsd/tunDevice.cpp +++ b/src/bsd/tunDevice.cpp @@ -47,6 +47,8 @@ #include "tunDevice.h" #include "threadUtils.hpp" #include "log.h" +#include "anytunError.hpp" + #define DEVICE_FILE_MAX 255 TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifcfg_addr, std::string ifcfg_prefix) : conf_(dev_name, dev_type, ifcfg_addr, ifcfg_prefix, 1400) @@ -73,7 +75,7 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc } #endif else - throw std::runtime_error("unable to recognize type of device (tun or tap)"); + AnytunError::throwErr() << "unable to recognize type of device (tun or tap)"; u_int32_t dev_id=0; if(dynamic) { @@ -90,12 +92,10 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc fd_ = ::open(device_file.c_str(), O_RDWR); if(fd_ < 0) { - std::stringstream msg; if(dynamic) - msg << "can't open device file dynamically: no unused node left"; + AnytunError::throwErr() << "can't open device file dynamically: no unused node left"; else - msg << "can't open device file (" << device_file << "): " << LogErrno(errno); - throw std::runtime_error(msg.str()); + AnytunError::throwErr() << "can't open device file (" << device_file << "): " << LogErrno(errno); } if(dynamic) { @@ -133,7 +133,7 @@ void TunDevice::init_post() if (ioctl(fd_, TUNGIFINFO, &ti) < 0) { ::close(fd_); - throw std::runtime_error("can't enable multicast for interface"); + AnytunError::throwErr() << "can't enable multicast for interface"; } ti.flags |= IFF_MULTICAST; @@ -142,7 +142,7 @@ void TunDevice::init_post() if (ioctl(fd_, TUNSIFINFO, &ti) < 0) { ::close(fd_); - throw std::runtime_error("can't enable multicast for interface"); + AnytunError::throwErr() << "can't enable multicast for interface"; } } -- cgit v1.2.3