herr.c 358 B

12345678910111213141516171819
  1. #include "herr.h"
  2. #include <string.h> // for strerror
  3. // errcode => errmsg
  4. const char* hv_strerror(int err) {
  5. if (err > 0 && err <= SYS_NERR) {
  6. return strerror(err);
  7. }
  8. switch (err) {
  9. #define F(errcode, name, errmsg) \
  10. case errcode: return errmsg;
  11. FOREACH_ERR(F)
  12. #undef F
  13. default:
  14. return "Undefined error";
  15. }
  16. }