Utils: Implement more flexible SystemException
[senf.git] / Socket / FileHandle.cc
index bdc4eca..7aa9e24 100644 (file)
@@ -33,7 +33,7 @@
 #include <string.h>
 #include <errno.h>
 #include <fcntl.h>
-#include "Utils/Exception.hh"
+#include "../Utils/Exception.hh"
 
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
@@ -41,7 +41,7 @@
 prefix_ void senf::FileBody::v_close()
 {
     if (::close(fd_) != 0)
-        throw SystemException(errno);
+        throwErrno();
 }
 
 prefix_ void senf::FileBody::v_terminate()
@@ -65,17 +65,17 @@ prefix_ bool senf::FileBody::blocking()
     const
 {
     int flags = ::fcntl(fd(),F_GETFL);
-    if (flags < 0) throw SystemException(errno);
+    if (flags < 0) throwErrno();
     return ! (flags & O_NONBLOCK);
 }
 
 prefix_ void senf::FileBody::blocking(bool status)
 {
     int flags = ::fcntl(fd(),F_GETFL);
-    if (flags < 0) throw SystemException(errno);
+    if (flags < 0) throwErrno();
     if (status) flags &= ~O_NONBLOCK;
     else        flags |= O_NONBLOCK;
-    if (::fcntl(fd(), F_SETFL, flags) < 0) throw SystemException(errno);
+    if (::fcntl(fd(), F_SETFL, flags) < 0) throwErrno();
 }
 
 /* We don't take POLLIN/POLLOUT as argument to avoid having to include
@@ -96,7 +96,7 @@ prefix_ bool senf::FileBody::pollCheck(int fd, bool incoming, bool block)
             case EINTR:
                 break;
             default:
-                throw SystemException(errno);
+                throwErrno();
             }
     } while (rv<0);
     return rv>0;
@@ -112,4 +112,6 @@ prefix_ bool senf::FileBody::pollCheck(int fd, bool incoming, bool block)
 // c-file-style: "senf"
 // indent-tabs-mode: nil
 // ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
 // End: