Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1192)

Unified Diff: bin/process_win.cc

Issue 8277035: Get the OS error message for process exceptions on Windows (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/process_win.cc
===================================================================
--- bin/process_win.cc (revision 433)
+++ bin/process_win.cc (working copy)
@@ -180,11 +180,23 @@
}
static int SetOsErrorMessage(char* os_error_message,
- int os_error_message_len) {
+ int os_error_message_len) {
int error_code = GetLastError();
- // TODO(sgjesse): Use FormatMessage to get the error message.
- char message[80];
- snprintf(os_error_message, os_error_message_len, "OS Error %d", error_code);
+ DWORD message_size =
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ error_code,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ os_error_message,
+ os_error_message_len,
+ NULL);
+ if (message_size == 0) {
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ fprintf(stderr, "FormatMessage failed %d\n", GetLastError());
+ }
+ snprintf(os_error_message, os_error_message_len, "OS Error %d", error_code);
+ }
+ os_error_message[os_error_message_len - 1] = '\0';
return error_code;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698