case EINTR:
break;
default:
- throw SystemException();
+ throw SystemException("ConnectedCommunicationPolicy::do_accept failed.");
}
} while (rv<0);
return rv;
{
sockfd_ = ::socket( PF_INET, SOCK_DGRAM, 0);
if ( sockfd_ < 0)
- throw SystemException( "Could not open socket for NetdeviceController");
+ throw SystemException("Could not open socket for NetdeviceController.");
}
prefix_ void senf::NetdeviceController::ifrName(ifreq& ifr)
::memset( &ifr, 0, sizeof(ifr));
ifr.ifr_ifindex = ifindex_;
if ( ::ioctl( sockfd_, SIOCGIFNAME, &ifr ) < 0 )
- throw SystemException(
- "NetdeviceController: Could not discover the name of the interface with index ") << ifindex_;
+ throw SystemException("NetdeviceController")
+ << " could not discover the name of the interface with index " << ifindex_ << ".";
}
prefix_ void senf::NetdeviceController::doIoctl(ifreq& ifr, int request)
const
{
if ( ::ioctl( sockfd_, request, &ifr ) < 0 )
- throw SystemException();
+ throw SystemException("NetdeviceController::doIoctl failed.");
}
///////////////////////////////cc.e////////////////////////////////////////
"/dev/dvb/adapter%d/demux%d") % adapter % device);
int f = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK);
if (f < 0){
- throw SystemException( "Could not open demux device of DVB adapter ") << devDemux;
+ throw SystemException("Could not open demux device of DVB adapter ") << devDemux << ".";
}
fd(f);
}
const
{
if (::ioctl(fd(), DMX_SET_FILTER, filter) < 0)
- throw SystemException("Could not set section filter of DVB adapter");
+ throw SystemException("Could not set section filter of DVB adapter.");
}
// ----------------------------------------------------------------
"/dev/dvb/adapter%d/demux%d") % adapter % device);
int f = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK);
if (f < 0)
- throw SystemException( "Could not open demux device of DVB adapter ") << devDemux;
+ throw SystemException( "Could not open demux device of DVB adapter ") << devDemux << ".";
fd(f);
}
const
{
if (::ioctl(fd(), DMX_SET_PES_FILTER, filter) < 0)
- throw SystemException("Could not set PES filter of DVB adapter");
+ throw SystemException("Could not set PES filter of DVB adapter.");
}
// ----------------------------------------------------------------
"/dev/dvb/adapter%d/dvr%d") % adapter % device);
int f = open(devDvr.c_str(), O_RDONLY | O_NONBLOCK);
if (f < 0)
- throw SystemException( "Could not open dvr device of DVB adapter ") << devDvr;
+ throw SystemException( "Could not open dvr device of DVB adapter ") << devDvr << ".";
fd(f);
}
const
{
if (::ioctl(fd(), DMX_SET_BUFFER_SIZE, size) < 0)
- throw SystemException(
- "Could not set the size of the buffer on DVB adapter. requested size: ") << size;
+ throw SystemException()
+ << "Could not set the size of the buffer on DVB adapter. requested size: "
+ << size << ".";
}
prefix_ void senf::DVBDemuxSocketProtocol::startFiltering()
const
{
if (::ioctl(fd(), DMX_START) < 0)
- throw SystemException("Could not start filtering operation on DVB adapter");
+ throw SystemException("Could not start filtering operation on DVB adapter.");
}
prefix_ void senf::DVBDemuxSocketProtocol::stopFiltering()
const
{
if (::ioctl(fd(), DMX_STOP) < 0)
- throw SystemException("Could not stop filtering operation on DVB adapter");
+ throw SystemException("Could not stop filtering operation on DVB adapter.");
}
prefix_ bool senf::DVBDemuxSocketProtocol::eof()
"/dev/dvb/adapter%d/frontend%d") % adapter % device);
int f = open(devFrontend.c_str(), O_RDONLY | O_NONBLOCK);
if (f < 0)
- throw SystemException("Could not open frontend device of DVB adapter ")<< devFrontend;
+ throw SystemException() << "Could not open frontend device of DVB adapter " << devFrontend << ".";
fd(f);
}
const
{
if (::ioctl(fd(), FE_READ_SIGNAL_STRENGTH, strength) < 0)
- throw SystemException( "Could not get signal strength of DVB adapter");
+ throw SystemException( "Could not get signal strength of DVB adapter.");
}
///////////////////////////////cc.e////////////////////////////////////////
{
int sock = ::socket(PF_INET,SOCK_DGRAM,0);
if (sock < 0)
- throw SystemException();
+ throw SystemException("::socket(PF_INET,SOCK_DGRAM,0) failed.");
fd(sock);
}
{
int sock = ::socket(PF_INET6,SOCK_DGRAM,0);
if (sock < 0)
- throw SystemException();
+ throw SystemException("::socket(PF_INET6,SOCK_DGRAM,0) failed.");
fd(sock);
}
mreqn.imr_address.s_addr = htons(INADDR_ANY);
mreqn.imr_ifindex = 0;
if (::setsockopt(fd(),SOL_IP,IP_ADD_MEMBERSHIP,&mreqn,sizeof(mreqn)) < 0)
- throw SystemException("::setsockopt(IP_ADD_MEMBERSHIP");
+ throw SystemException("::setsockopt(IP_ADD_MEMBERSHIP)");
}
prefix_ void senf::INet4MulticastSocketProtocol::mcAddMembership(INet4Address const & mcAddr,
protocol = ETH_P_ALL;
int sock = ::socket(PF_PACKET, socktype, htons(protocol));
if (sock < 0)
- throw SystemException();
+ throw SystemException("::socket(...) failed.");
fd(sock);
}
return 0;
ssize_t l = ::recv(fd(),0,0,MSG_PEEK | MSG_TRUNC);
if (l < 0)
- throw SystemException();
+ throw SystemException("::recv(socket_fd) failed.");
return l;
}
{
int f;
if ( (f = ::open("/dev/net/tun", O_RDWR)) < 0 )
- throw SystemException( "Could not open tap control device: /dev/net/tun");
+ throw SystemException( "Could not open tap control device: /dev/net/tun.");
struct ifreq ifr;
::memset( &ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP;
ifr.ifr_flags |= IFF_NO_PI;
interface_name.copy( ifr.ifr_name, IFNAMSIZ);
if (::ioctl(f, TUNSETIFF, (void *) &ifr) < 0 )
- throw SystemException( "Could not create tap device: ") << ifr.ifr_name;
+ throw SystemException( "Could not create tap device: ") << ifr.ifr_name << ".";
fd(f);
}
{
int sock = ::socket(PF_UNIX,SOCK_DGRAM,0);
if (sock < 0)
- throw SystemException( "Could not create socket(PF_UNIX,SOCK_DGRAM,0)" );
+ throw SystemException( "Could not create socket(PF_UNIX,SOCK_DGRAM,0)." );
fd(sock);
}
{
int sock = ::socket(PF_UNIX,SOCK_DGRAM,0);
if (sock < 0)
- throw SystemException( "Could not create socket(PF_UNIX,SOCK_DGRAM,0)" );
+ throw SystemException( "Could not create socket(PF_UNIX,SOCK_DGRAM,0)." );
fd(sock);
}
{
int n;
if (::ioctl(fd(),SIOCINQ,&n) < 0)
- throw SystemException("Could not call available() on UNSocket");
+ throw SystemException("Could not call available() on UNSocket.");
return n;
}
::unlink(una.path().c_str());
}
catch (SystemException & e) {
- SENF_LOG(("UNSocketProtocol::check_and_unlink() failed; " << e.errorString() ));
+ SENF_LOG(("UNSocketProtocol::check_and_unlink() failed; [" << e.errorString() << "]."));
}
}
const
{
if (::shutdown(body().fd(),SHUT_RDWR) < 0)
- throw SystemException();
+ throw SystemException("::shutdown(socket_fd)");
if (::close(body().fd()) < 0)
- throw SystemException();
+ throw SystemException("::close(socket_fd)");
}
prefix_ void senf::SocketProtocol::terminate()
if (! stdoutLog_.empty()) {
fd = ::open(stdoutLog_.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0666);
if (fd < 0)
- throw SystemException("::open()");
+ throw SystemException()
+ << " Could not open \"" << stdoutLog_ << "\" for redirecting stdout.";
stdout_ = fd;
}
if (stderrLog_ == stdoutLog_)
else if (! stderrLog_.empty()) {
fd = ::open(stdoutLog_.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0666);
if (fd < 0)
- throw SystemException("::open()");
+ throw SystemException()
+ << " Could not open \"" << stderrLog_ << "\" for redirecting stderr.";
stderr_ = fd;
}
}
// was some race condition, probably over NFS.
std::string tempname;
- boost::format linkErrorFormat("; could not link \"%1%\" to \"%2%\".");
+ boost::format linkErrorFormat(" Could not link \"%1%\" to \"%2%\".");
{
char hostname[HOST_NAME_MAX+1];
while (1) {
{
std::ofstream pidf (tempname.c_str());
+ if (! pidf)
+ throw SystemException()
+ << " Could not open pidfile \"" << tempname << "\" for output.";
pidf << ::getpid() << std::endl;
+ if (! pidf)
+ throw SystemException()
+ << " Could not write to pidfile \"" << tempname << "\".";
}
if (::link(tempname.c_str(), pidfile_.c_str()) < 0) {
if (errno != EEXIST)
- throw SystemException("::link()")
- << linkErrorFormat % pidfile_.c_str() % tempname.c_str();
+ throw SystemException() << linkErrorFormat % pidfile_ % tempname;
}
else {
struct ::stat s;
LIBC_CALL( ::unlink, (tempname.c_str() ));
if (::link(pidfile_.c_str(), tempname.c_str()) < 0) {
if (errno != ENOENT)
- throw SystemException("::link()")
- << linkErrorFormat % tempname.c_str() % pidfile_.c_str();
+ throw SystemException() << linkErrorFormat % tempname % pidfile_;
// Hmm ... the pidfile mysteriously disappeared ... try again.
continue;
}
{
code_ = code;
(*this) << "[" << errorString() << "]";
- if (! descr.empty()) (*this) << "; " << descr;
+ if (! descr.empty()) (*this) << " " << descr;
}
///////////////////////////////cc.e////////////////////////////////////////
}
catch (senf::SystemException & e) {
BOOST_CHECK_EQUAL( e.errorNumber(), ENOENT );
- //BOOST_CHECK_EQUAL( e.what(), "::open(): (2) No such file or directory\nx=1\ny=2" );
- BOOST_CHECK_EQUAL( e.what(), "[No such file or directory]; ::open()\nx=1\ny=2" );
+ BOOST_CHECK_EQUAL( e.errorString(), "No such file or directory");
}
}