]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2369] Describe why the operation failed in OpenError exception
authorMukund Sivaraman <muks@isc.org>
Tue, 6 Nov 2012 04:27:39 +0000 (09:57 +0530)
committerMukund Sivaraman <muks@isc.org>
Tue, 6 Nov 2012 04:27:39 +0000 (09:57 +0530)
src/lib/dns/master_lexer_inputsource.cc

index 517ffeb903bae6606474886d684b1c799cf77ee5..5d8d41343bc2b26b91a6af47e65f9a5670256d12 100644 (file)
@@ -14,6 +14,9 @@
 
 #include <dns/master_lexer_inputsource.h>
 
+#include <cerrno>
+#include <cstring>
+
 namespace isc {
 namespace dns {
 namespace master_lexer_internal {
@@ -46,10 +49,16 @@ InputSource::InputSource(const char* filename) :
     name_(filename),
     input_(file_stream_)
 {
+    errno = 0;
     file_stream_.open(filename);
     if (file_stream_.fail()) {
-        isc_throw(OpenError,
-                  "Error opening the input source file: " << filename);
+        std::string error_txt("Error opening the input source file: ");
+        error_txt += filename;
+        if (errno != 0) {
+            error_txt += "; possible cause: ";
+            error_txt += std::strerror(errno);
+        }
+        isc_throw(OpenError, error_txt);
     }
 }