utils.h 286 Bytes Edit Raw Blame History 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #ifndef UTILS_H #define UTILS_H #include <string.h> #include <errno.h> #include <string> template<typename T> int check(int rc) { if (rc < 0) { char *err = strerror(errno); std::string msg(err); throw T(msg); } return rc; } #endif // UTILS_H