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

Unified Diff: runtime/bin/utils_win.cc

Issue 9630012: Error reporting on File in dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Style issues Created 8 years, 9 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 | « runtime/bin/utils_macos.cc ('k') | tests/standalone/src/io/DirectoryTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/utils_win.cc
diff --git a/runtime/bin/utils_win.cc b/runtime/bin/utils_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..29491cba5b4f33b42c8330f36a9d814f9578eb0e
--- /dev/null
+++ b/runtime/bin/utils_win.cc
@@ -0,0 +1,31 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include <errno.h>
+
+#include "bin/utils.h"
+
+OSError::OSError() : code_(0), message_(NULL) {
+ set_code(GetLastError());
+
+ static const int kMaxMessageLength = 256;
+ char message[kMaxMessageLength];
+ DWORD message_size =
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ code_,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ message,
+ kMaxMessageLength,
+ NULL);
+ if (message_size == 0) {
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ fprintf(stderr, "FormatMessage failed %d\n", GetLastError());
+ }
+ snprintf(message, kMaxMessageLength, "OS Error %d", code_);
+ }
+ message[kMaxMessageLength - 1] = '\0';
+
+ SetMessage(message);
+}
« no previous file with comments | « runtime/bin/utils_macos.cc ('k') | tests/standalone/src/io/DirectoryTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698