diff --git a/src/tengfilesystem.cc b/src/tengfilesystem.cc index 1f4a802..de65057 100644 --- a/src/tengfilesystem.cc +++ b/src/tengfilesystem.cc @@ -38,7 +38,7 @@ std::string Filesystem_t::read(const std::string& filename_) const tengNormalizeFilename(filename); FILE* fp = fopen(filename.c_str(), "rb"); - if (fp == 0) throw std::runtime_error("fopen(" + filename + ")"); + if (fp == 0) throw std::runtime_error("Cannot open input file '" + filename + "'"); char buf[1024]; int i; diff --git a/src/tenglex1.cc b/src/tenglex1.cc index a558b06..6ad41ba 100644 --- a/src/tenglex1.cc +++ b/src/tenglex1.cc @@ -55,16 +55,18 @@ Lex1_t::Lex1_t(const std::string &input, const std::string &fname) /** Initialize lexical analyzer from file. * @param filesystem Filesystem to use. * @param input Input file to read. */ -Lex1_t::Lex1_t(const FilesystemInterface_t *filesystem, - const std::string &fname, - const Error_t::Position_t &position, - Error_t &error) -try - : input(filesystem->read(fname)), position(0), filename(fname), line(1), column(0) +Lex1_t::Lex1_t(const FilesystemInterface_t* filesystem, + const std::string& fname, + const Error_t::Position_t& position, + Error_t& error) + : position(0), filename(fname), line(1), column(0) { -} -catch (const std::exception &e) { - error.logSyscallError(Error_t::LL_ERROR, position, e.what()); + try { + input = filesystem->read(fname); + } + catch (const std::exception& e) { + error.logSyscallError(Error_t::LL_ERROR, position, e.what()); + } }