summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2003-07-13 01:32:43 +0000
committerpixel <pixel>2003-07-13 01:32:43 +0000
commit2a1525eb8cef13000fc10126f770541b2115ff89 (patch)
treebe6312f2dd6fe8454e8a7574f95b5eb44564d585
parentc477f1a35d23a9a3d3e29622b013532343c078cc (diff)
Misc fixes
-rw-r--r--include/Handle.h2
-rw-r--r--lib/Handle.cc13
-rw-r--r--lib/Input.cc5
-rw-r--r--lib/Main.cc1
4 files changed, 15 insertions, 6 deletions
diff --git a/include/Handle.h b/include/Handle.h
index 5d0bdee..6e0fcbc 100644
--- a/include/Handle.h
+++ b/include/Handle.h
@@ -35,7 +35,7 @@ class Handle : public Base {
void close() throw (GeneralException);
int GetHandle();
virtual bool CanWatch() const;
- virtual int Dup() const;
+ virtual int Dup() const throw (GeneralException);
virtual void SetZ(int = 9) throw (GeneralException);
virtual void Flush();
protected:
diff --git a/lib/Handle.cc b/lib/Handle.cc
index d366382..69f6111 100644
--- a/lib/Handle.cc
+++ b/lib/Handle.cc
@@ -209,12 +209,12 @@ void Handle::close() throw (GeneralException) {
if (c == DEFLATE) {
err = deflateEnd(&zstrm);
if (err != Z_OK) {
- throw (String(_("Error during deflateEnd: ")) + zstrm.msg);
+ throw GeneralException(String(_("Error during deflateEnd: ")) + zstrm.msg);
}
} else {
err = inflateEnd(&zstrm);
if (err != Z_OK) {
- throw (String(_("Error during inflateEnd: ")) + zstrm.msg);
+ throw GeneralException(String(_("Error during inflateEnd: ")) + zstrm.msg);
}
}
err = ::close(h);
@@ -273,8 +273,13 @@ bool Handle::CanWatch(void) const {
return true;
}
-int Handle::Dup() const {
- return dup(h);
+int Handle::Dup() const throw (GeneralException) {
+ int d;
+
+ if ((d = dup(h)) < 0) {
+ throw IOGeneral(String(_("Error dupping file `")) + GetName() + _("' (handle ") + h + "): " + strerror(errno) + " (" + errno + ")");
+ }
+ return d;
}
void Handle::SetZ(int az) throw (GeneralException) {
diff --git a/lib/Input.cc b/lib/Input.cc
index ed549ec..d846acd 100644
--- a/lib/Input.cc
+++ b/lib/Input.cc
@@ -5,6 +5,8 @@
#include <sys/stat.h>
#include <fcntl.h>
+#define DEBUG
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -70,10 +72,11 @@ Input::Input(const String & no) throw (GeneralException) :
n(no) {
#ifdef DEBUG
- fprintf(stderr, _("Opening file %s, Input at %p\n"), no.to_charp(), this);
+ printm(M_BARE, String(_("Opening file")) + no + _("Input at %p\n"), this);
#endif
if (GetHandle() < 0) {
+ printm(M_BARE, "Got handle: %i\n", GetHandle());
throw IOGeneral(String(_("Error opening file ")) + no + _(" for reading: ") + strerror(errno));
}
diff --git a/lib/Main.cc b/lib/Main.cc
index 9e2891b..74b83cc 100644
--- a/lib/Main.cc
+++ b/lib/Main.cc
@@ -1,6 +1,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include "Exceptions.h"
#include "Main.h"
#include "generic.h"
//#include "gettext.h"