Skip to content

Commit

Permalink
fix not caught exception and change error to be the same as previous …
Browse files Browse the repository at this point in the history
…version
  • Loading branch information
Frantisek Boranek committed Sep 19, 2018
1 parent 0cabcd5 commit 014078f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/tengfilesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 11 additions & 9 deletions src/tenglex1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}


Expand Down

0 comments on commit 014078f

Please sign in to comment.