Browse Source

[2369] Describe why the operation failed in OpenError exception

Mukund Sivaraman 12 years ago
parent
commit
ff7cec44f4
1 changed files with 11 additions and 2 deletions
  1. 11 2
      src/lib/dns/master_lexer_inputsource.cc

+ 11 - 2
src/lib/dns/master_lexer_inputsource.cc

@@ -14,6 +14,9 @@
 
 
 #include <dns/master_lexer_inputsource.h>
 #include <dns/master_lexer_inputsource.h>
 
 
+#include <cerrno>
+#include <cstring>
+
 namespace isc {
 namespace isc {
 namespace dns {
 namespace dns {
 namespace master_lexer_internal {
 namespace master_lexer_internal {
@@ -46,10 +49,16 @@ InputSource::InputSource(const char* filename) :
     name_(filename),
     name_(filename),
     input_(file_stream_)
     input_(file_stream_)
 {
 {
+    errno = 0;
     file_stream_.open(filename);
     file_stream_.open(filename);
     if (file_stream_.fail()) {
     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);
     }
     }
 }
 }