summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-09-08 01:47:02 +0000
committerrandomdan <randomdan@localhost>2010-09-08 01:47:02 +0000
commit9cfb7dbe44d198fb859635217344a90b1bb9f012 (patch)
treec263aa29ea7d66b1862afcad8c284e5e06aa4b84
parentAdd some missing virtual destructors (diff)
downloadproject2-9cfb7dbe44d198fb859635217344a90b1bb9f012.tar.bz2
project2-9cfb7dbe44d198fb859635217344a90b1bb9f012.tar.xz
project2-9cfb7dbe44d198fb859635217344a90b1bb9f012.zip
Add some error handling to ProcRows
-rw-r--r--project2/procRows.cpp12
-rw-r--r--project2/procRows.h1
2 files changed, 12 insertions, 1 deletions
diff --git a/project2/procRows.cpp b/project2/procRows.cpp
index f4d0f50..e5ed86a 100644
--- a/project2/procRows.cpp
+++ b/project2/procRows.cpp
@@ -25,7 +25,17 @@ _ProcRows::doOpen() const
if (!f) {
throw std::runtime_error("Could not open file");
}
- return FileStarChannel(f, false, pclose);
+ return FileStarChannel(f, false, doClose);
+}
+
+int
+_ProcRows::doClose(FILE * f)
+{
+ int pclo = pclose(f);
+ if (pclo != 0) {
+ throw std::runtime_error("Subprocess returned an error");
+ }
+ return 0;
}
#include "view.hpp"
diff --git a/project2/procRows.h b/project2/procRows.h
index 02add07..e28a5f5 100644
--- a/project2/procRows.h
+++ b/project2/procRows.h
@@ -10,6 +10,7 @@ class _ProcRows : public _FileRows {
virtual void loadComplete();
virtual FileStarChannel doOpen() const;
+ static int doClose(FILE*);
};
typedef _GenericView<_ProcRows> _ProcView;
typedef _GenericIterate<_ProcRows> _ProcIterate;