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

Unified Diff: runtime/bin/common.dart

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/builtin_natives.cc ('k') | runtime/bin/dartutils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/common.dart
diff --git a/runtime/bin/common.dart b/runtime/bin/common.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b1f7da882b7ce550031f1493c1ae9e0d32aa6002
--- /dev/null
+++ b/runtime/bin/common.dart
@@ -0,0 +1,55 @@
+// 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.
+
+/**
+ * An [OSError] object holds information about an error from the
+ * operating system.
+ */
+class OSError {
+ static final int noErrorCode = -1;
+
+ const OSError([String this.message = "", int this.errorCode = noErrorCode]);
+
+ String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.add("OS Error");
+ if (!message.isEmpty()) {
+ sb.add(": ");
+ sb.add(message);
+ if (errorCode != noErrorCode) {
+ sb.add(", errno = ");
+ sb.add(errorCode.toString());
+ }
+ } else if (errorCode != noErrorCode) {
+ sb.add(": errno = ");
+ sb.add(errorCode.toString());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Error message supplied by the operating system. null if no message is
+ * associated with the error.
+ */
+ final String message;
+
+ /**
+ * Error code supplied by the operating system. Will have the value
+ * [noErrorCode] if there is no error code associated with the error.
+ */
+ final int errorCode;
+}
+
+
+/**
+ * Utility for creating an OSError instance. NOTE: This will go away
+ * soon, so please don't use this utility function. The reason for
+ * having it temporarily is that the Dart C API does not currently
+ * support constructing objects.
+ */
+// TODO(sgjesse): Remove this once Dart constructors can be invoked
+// through the API.
+class IOUtils {
+ static OSError makeOSError(message, code) => new OSError(message, code);
+}
« no previous file with comments | « runtime/bin/builtin_natives.cc ('k') | runtime/bin/dartutils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698