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
commitdf0d0a847c6cc0c525d0ad6b8b07854dba24f47b (patch)
treec263aa29ea7d66b1862afcad8c284e5e06aa4b84
parentAdd some missing virtual destructors (diff)
downloadproject2-df0d0a847c6cc0c525d0ad6b8b07854dba24f47b.tar.bz2
project2-df0d0a847c6cc0c525d0ad6b8b07854dba24f47b.tar.xz
project2-df0d0a847c6cc0c525d0ad6b8b07854dba24f47b.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;