From 1c5626cd8a3dd28d7d09e01d6d3b95f49f10e421 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 15 Jan 2009 16:28:12 +0000 Subject: log class can now easily use errno and gpg_err --- src/bsd/tunDevice.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/bsd/tunDevice.cpp') diff --git a/src/bsd/tunDevice.cpp b/src/bsd/tunDevice.cpp index 31e986c..ce2a413 100644 --- a/src/bsd/tunDevice.cpp +++ b/src/bsd/tunDevice.cpp @@ -46,10 +46,9 @@ #include "tunDevice.h" #include "threadUtils.hpp" +#include "log.h" #define DEVICE_FILE_MAX 255 -#include - TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifcfg_lp, std::string ifcfg_rnmp) : conf_(dev_name, dev_type, ifcfg_lp, ifcfg_rnmp, 1400) { std::string device_file = "/dev/"; @@ -84,19 +83,12 @@ 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::string msg; + std::stringstream msg; if(dynamic) - msg = "can't open device file dynamically: no unused node left"; - else { - msg = "can't open device file ("; - msg.append(device_file); - msg.append("): "); - char buf[STERROR_TEXT_MAX]; - buf[0] = 0; - strerror_r(errno, buf, STERROR_TEXT_MAX); - msg.append(buf); - } - throw std::runtime_error(msg); + msg << "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()); } if(dynamic) { -- cgit v1.2.3