Files
sdk/runtime/bin/common.dart
T
ager@google.com eafaf035d2 Make the temporary OSError allocation method private.
GetField, SetField, Invoke can now be called with a library target
and with private names. Using that we can make this temporary
utility function private as it should be.

Work is under way to support instance creation through the API.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9773037

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5881 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-27 15:31:00 +00:00

48 lines
1.3 KiB
Dart

// 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;
}
// TODO(sgjesse): Remove this once Dart constructors can be invoked
// through the API.
OSError _makeOSError(message, code) => new OSError(message, code);