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

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: Made Dart OSError constructor const 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
Index: runtime/bin/common.dart
diff --git a/runtime/bin/common.dart b/runtime/bin/common.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b46c01de76671ddc41da0da14e48fa1574c565e5
--- /dev/null
+++ b/runtime/bin/common.dart
@@ -0,0 +1,47 @@
+// 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.
+
+/**
+ * Class for holding information on an error that was returned from the
+ * operating system.
+ */
+class OSError {
+ static int noErrorCode = -1;
+
+ const OSError([String this.message, int this.errorCode = -1]);
+
+ String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.add("OS Error");
+ if (message != null && message.length > 0) {
+ 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;
+}
+
+
+class IOUtils {
+ static OSError makeOSError(message, code) => new OSError(message, code);
Mads Ager (google) 2012/03/09 09:40:13 We should get rid of this public class and public
Søren Gjesse 2012/03/13 08:25:55 Added TODO and filed issue 2081.
+}

Powered by Google App Engine
This is Rietveld 408576698