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.
|
+} |