src/node.cc
// Does about the same as strerror(),
// but supports all windows error messages
Does about the same as strerror(),
but supports all windows error messages
Does about the same as strerror () but supports all windows error messages
static const char *winapi_strerror(const int errorno, bool* must_free) {
  char *errmsg = nullptr;
  FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
      FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, errorno,
      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&errmsg, 0, nullptr);
  if (errmsg) {
    *must_free = true;
    for (int i = strlen(errmsg) - 1;
        i >= 0 && (errmsg[i] == '\n' || errmsg[i] == '\r'); i--) {
      errmsg[i] = '\0';
    }
    return errmsg;
  } else {
    *must_free = false;
    return "Unknown error";
  }
}
static const char * winapi_strerror ( const int errorno , bool * must_free ) { char * errmsg = nullptr ; FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS , nullptr , errorno , MAKELANGID ( LANG_NEUTRAL , SUBLANG_DEFAULT ) , ( LPTSTR ) & errmsg , 0 , nullptr ) ; if ( errmsg ) { * must_free = true ; for ( int i = strlen ( errmsg ) - 1 ; i >= 0 && ( errmsg [ i ] == ' \n ' || errmsg [ i ] == ' \r ' ) ; i -- ) { errmsg [ i ] = ' \0 ' ; } return errmsg ; } else { * must_free = false ; return " " ; } }
Does about the same as strerror(),
but supports all windows error messages
Does about the same as strerror () but supports all windows error messages
// Remove trailing newlines // FormatMessage failed