Commit 6d52539b authored by Ludovic Courtès's avatar Ludovic Courtès

common: Separate errno handling in CATCH_FILE_IO_ERROR.

parent ba486c47
......@@ -450,27 +450,25 @@ class header
#include <iostream>
#include <cstdlib>
#ifndef _WIN32
# define CATCH_FILE_IO_ERROR(file) \
catch (std::ios_base::failure& e) { \
std::cerr << "<<ERROR>> failed to load '" \
<< (file) << "'" \
<< ": " << strerror(errno) \
<< std::endl; \
exit(EXIT_FAILURE); \
}
#ifdef _WIN32
// We cannot rely on 'errno' on Windows.
# define ALTA_FILE_IO_ERROR_STRING(e) \
"(unspecified I/O error)"
#else
// We cannot rely on 'errno' on Windows.
# define ALTA_FILE_IO_ERROR_STRING(e) \
(strerror(errno))
# define CATCH_FILE_IO_ERROR(file) \
catch (std::ios_base::failure& e) { \
std::cerr << "<<ERROR>> failed to load '" \
<< (file) << "'" \
<< std::endl; \
exit(EXIT_FAILURE); \
}
#endif
#endif /* _WIN32 */
# define CATCH_FILE_IO_ERROR(file) \
catch (std::ios_base::failure& e) { \
std::cerr << "<<ERROR>> failed to load '" \
<< (file) << "'" \
<< ": " << ALTA_FILE_IO_ERROR_STRING(e) \
<< std::endl; \
exit(EXIT_FAILURE); \
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment