From 341dc50ab705a7ea67ed5a74e67e8dab5dfd792f Mon Sep 17 00:00:00 2001 From: gereon Date: Fri, 15 Mar 2013 14:08:37 +0100 Subject: [PATCH] Added some better error output for basic parsers using errno --- src/parser/Parser.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/parser/Parser.cpp b/src/parser/Parser.cpp index d84ed6ab6..5234d3bf9 100644 --- a/src/parser/Parser.cpp +++ b/src/parser/Parser.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "src/exceptions/FileIoException.h" #include "src/exceptions/WrongFileFormatException.h" @@ -75,21 +76,21 @@ storm::parser::MappedFile::MappedFile(const char* filename) { #else if (stat64(filename, &(this->st)) != 0) { #endif - LOG4CPLUS_ERROR(logger, "Error in stat(" << filename << ")."); - throw exceptions::FileIoException("storm::parser::MappedFile Error in stat()"); + LOG4CPLUS_ERROR(logger, "Error in stat(" << filename << "): " << std::strerror(errno)); + throw exceptions::FileIoException() << "storm::parser::MappedFile Error in stat(): " << std::strerror(errno); } this->file = open(filename, O_RDONLY); if (this->file < 0) { - LOG4CPLUS_ERROR(logger, "Error in open(" << filename << ")."); - throw exceptions::FileIoException("storm::parser::MappedFile Error in open()"); + LOG4CPLUS_ERROR(logger, "Error in open(" << filename << "): " << std::strerror(errno)); + throw exceptions::FileIoException() << "storm::parser::MappedFile Error in open(): " << std::strerror(errno); } this->data = reinterpret_cast(mmap(NULL, this->st.st_size, PROT_READ, MAP_PRIVATE, this->file, 0)); if (this->data == reinterpret_cast(-1)) { close(this->file); - LOG4CPLUS_ERROR(logger, "Error in mmap(" << filename << ")."); - throw exceptions::FileIoException("storm::parser::MappedFile Error in mmap()"); + LOG4CPLUS_ERROR(logger, "Error in mmap(" << filename << "): " << std::strerror(errno)); + throw exceptions::FileIoException() << "storm::parser::MappedFile Error in mmap(): " << std::strerror(errno); } this->dataend = this->data + this->st.st_size; #elif defined WINDOWS