diff options
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/os_windows.cpp | 20 | ||||
-rw-r--r-- | platform/windows/stream_peer_winsock.cpp | 4 |
2 files changed, 21 insertions, 3 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 3bdc307c3a..9bcbb6ddb6 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -69,8 +69,26 @@ __attribute__((visibility("default"))) DWORD NvOptimusEnablement = 0x00000001; #define WM_TOUCH 576 #endif +static String format_error_message(DWORD id) { + + LPWSTR messageBuffer = NULL; + size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, NULL); + + String msg = "Error "+itos(id)+": "+String(messageBuffer,size); + + LocalFree(messageBuffer); + + return msg; + +} + + + extern HINSTANCE godot_hinstance; + + void RedirectIOToConsole() { int hConHandle; @@ -1604,7 +1622,7 @@ Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_han } if (!p_library_handle) { - ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + String::num(GetLastError())); + ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + format_error_message(GetLastError())); ERR_FAIL_V(ERR_CANT_OPEN); } return OK; diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp index a9d9cb9373..8b83215325 100644 --- a/platform/windows/stream_peer_winsock.cpp +++ b/platform/windows/stream_peer_winsock.cpp @@ -141,7 +141,7 @@ Error StreamPeerWinsock::write(const uint8_t *p_data, int p_bytes, int &r_sent, if (WSAGetLastError() != WSAEWOULDBLOCK) { - perror("shit?"); + perror("Nothing sent"); disconnect_from_host(); ERR_PRINT("Server disconnected!\n"); return FAILED; @@ -197,7 +197,7 @@ Error StreamPeerWinsock::read(uint8_t *p_buffer, int p_bytes, int &r_received, b if (WSAGetLastError() != WSAEWOULDBLOCK) { - perror("shit?"); + perror("Nothing read"); disconnect_from_host(); ERR_PRINT("Server disconnected!\n"); return FAILED; |