 Chromium Code Reviews
 Chromium Code Reviews Issue 10540048:
  Implement 'as' operator.  (Closed) 
  Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
    
  
    Issue 10540048:
  Implement 'as' operator.  (Closed) 
  Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart| Index: corelib/src/exceptions.dart | 
| diff --git a/corelib/src/exceptions.dart b/corelib/src/exceptions.dart | 
| index 3e95797999cb3a90cce1e2ea8a3e4cd1c8b00e35..da213b6cd7007b1f2dbda6dfc7755acc600af542 100644 | 
| --- a/corelib/src/exceptions.dart | 
| +++ b/corelib/src/exceptions.dart | 
| @@ -38,7 +38,7 @@ class NoSuchMethodException implements Exception { | 
| const NoSuchMethodException(Object this._receiver, | 
| String this._functionName, | 
| List this._arguments, | 
| - [List existingArgumentNames = null]) : | 
| + [List existingArgumentNames = null]) : | 
| this._existingArgumentNames = existingArgumentNames; | 
| String toString() { | 
| @@ -140,6 +140,24 @@ class NullPointerException implements Exception { | 
| } | 
| +class CastException implements Exception { | 
| 
ahe
2012/06/25 10:36:56
We generally put fields before constructors which
 
Lasse Reichstein Nielsen
2012/06/25 11:20:06
I know. I was following the convention of the file
 
Lasse Reichstein Nielsen
2012/06/25 15:16:07
Ah, to heck with consistency. I'll move them up he
 | 
| + // TODO(lrn): Change expectedType to "Type" when reified types are in. | 
| 
ahe
2012/06/25 10:36:56
This comment applies to the field below.
 
Lasse Reichstein Nielsen
2012/06/25 11:20:06
True. I put the comment at the first instance of t
 | 
| + CastException(this.actualValue, this.expectedType); | 
| + String toString() { | 
| + if (expectedType !== null) { | 
| + return "$exceptionName : Casting $actualValue to $expectedType"; | 
| 
ahe
2012/06/25 10:36:56
You don't put a space after the exception. The abo
 
Lasse Reichstein Nielsen
2012/06/25 11:20:06
The actualValue is the value being cast, yes. As d
 
Lasse Reichstein Nielsen
2012/06/25 15:16:07
I also removed the special casing for when the typ
 | 
| + } else { | 
| + return "$exceptionName : Bad cast of $actualValue"; | 
| + } | 
| + } | 
| + | 
| + String get exceptionName() => "CastException"; | 
| 
ahe
2012/06/25 10:36:56
What is this for? Localization doesn't work well w
 
Lasse Reichstein Nielsen
2012/06/25 11:20:06
Again I'm following the surrounding code. I assume
 
ahe
2012/06/25 11:57:03
That the surrounding code is broken is no excuse f
 
Lasse Reichstein Nielsen
2012/06/25 12:51:10
I don't think the style guide makes any recommenda
 | 
| + | 
| + final Object actualValue; | 
| + final Object expectedType; | 
| +} | 
| + | 
| + | 
| class NoMoreElementsException implements Exception { | 
| const NoMoreElementsException(); | 
| String toString() => "NoMoreElementsException"; |