OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 /** | |
6 * Class for holding information on an error that was returned from the | |
Mads Ager (google)
2012/03/13 10:56:17
An [OSError] object holds information about an err
Søren Gjesse
2012/03/13 12:39:49
Done.
| |
7 * operating system. | |
8 */ | |
9 class OSError { | |
10 static int noErrorCode = -1; | |
Mads Ager (google)
2012/03/13 10:56:17
This should be final!
Søren Gjesse
2012/03/13 12:39:49
Absolutely, done.
| |
11 | |
12 const OSError([String this.message, int this.errorCode = -1]); | |
Mads Ager (google)
2012/03/13 10:56:17
The -1 here should be noErrorCode?
Søren Gjesse
2012/03/13 12:39:49
Yes, now that noErrorCode is final it can.
| |
13 | |
14 String toString() { | |
15 StringBuffer sb = new StringBuffer(); | |
16 sb.add("OS Error"); | |
17 if (message != null && message.length > 0) { | |
Mads Ager (google)
2012/03/13 10:56:17
How about making this.message the empty string by
Søren Gjesse
2012/03/13 12:39:49
Done.
| |
18 sb.add(": "); | |
19 sb.add(message); | |
20 if (errorCode != noErrorCode) { | |
21 sb.add(", errno = "); | |
22 sb.add(errorCode.toString()); | |
23 } | |
24 } else if (errorCode != noErrorCode) { | |
25 sb.add(": errno = "); | |
26 sb.add(errorCode.toString()); | |
27 } | |
28 return sb.toString(); | |
29 } | |
30 | |
31 /** | |
32 * Error message supplied by the operating system. null if no message is | |
33 * associated with the error. | |
34 */ | |
35 final String message; | |
36 | |
37 /** | |
38 * Error code supplied by the operating system. Will have the value | |
39 * [noErrorCode] if there is no error code associated with the error. | |
40 */ | |
41 final int errorCode; | |
42 } | |
43 | |
44 | |
45 // TODO(sgjesse): Remove this once Dart constructors can be invoked | |
Mads Ager (google)
2012/03/13 10:56:17
Please make this an actual doc comment where it sa
Søren Gjesse
2012/03/13 12:39:49
Done.
| |
46 // through the API. | |
47 class IOUtils { | |
48 static OSError makeOSError(message, code) => new OSError(message, code); | |
49 } | |
OLD | NEW |