Skip to content

Commit

Permalink
Merge pull request #579 from caiiiycuk/va_ioerror
Browse files Browse the repository at this point in the history
Better error message for I/O operations
  • Loading branch information
stalkerg committed May 12, 2022
2 parents 29907d8 + 9d4de50 commit f8320b3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/xtool/xstream/xsenlv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#include <iostream>
#include <fstream>

static const char *openMSG = "CREATE/OPEN FAILURE";

std::fstream *open_file(const char* name, unsigned f)
{
std::ios::openmode mode;
Expand Down Expand Up @@ -40,10 +38,15 @@ int XStream::open(const char* name, unsigned f)
#ifdef XSTREAM_DEBUG
std::cerr << "ERR: XStream::open(\"" << name << "\", 0x" << std::hex << f << ")" << std::endl;
#endif
if(ErrHUsed)
ErrH.Abort(openMSG,XERR_USER,0,smode.c_str());
else
if (ErrHUsed) {
char * error = strerror(errno);
ErrH.Abort((std::string("I/O Error: ") +
(error ? error : "unknown") +
" file: " + name).c_str(),
XERR_USER, 0, smode.c_str());
} else {
return 0;
}
}
return 1;
}
Expand Down

0 comments on commit f8320b3

Please sign in to comment.