Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:mirrors' show MirrorSystem; | 5 import 'dart:mirrors' show MirrorSystem; |
| 6 | 6 |
| 7 patch class Error { | 7 patch class Error { |
| 8 /* patch */ static String _objectToString(Object object) { | 8 /* patch */ static String _objectToString(Object object) { |
| 9 return Object._toString(object); | 9 return Object._toString(object); |
| 10 } | 10 } |
| 11 | 11 |
| 12 /* patch */ StackTrace get stackTrace => _stackTrace; | 12 /* patch */ StackTrace get stackTrace => _stackTrace; |
| 13 | 13 |
| 14 StackTrace _stackTrace; | 14 StackTrace _stackTrace; |
| 15 } | 15 } |
| 16 | 16 |
| 17 patch class AssertionError extends Error { | 17 class _AssertionError extends Error implements AssertionError { |
| 18 AssertionError._create( | 18 _AssertionError._create( |
|
Lasse Reichstein Nielsen
2014/10/21 07:53:43
This constructor doesn't even need to be named any
| |
| 19 this._failedAssertion, this._url, this._line, this._column); | 19 this._failedAssertion, this._url, this._line, this._column); |
| 20 | 20 |
| 21 static _throwNew(int assertionStart, int assertionEnd) | 21 static _throwNew(int assertionStart, int assertionEnd) |
| 22 native "AssertionError_throwNew"; | 22 native "AssertionError_throwNew"; |
| 23 | 23 |
| 24 String toString() { | 24 String toString() { |
| 25 var columnInfo = ""; | 25 var columnInfo = ""; |
| 26 if (_column > 0) { | 26 if (_column > 0) { |
| 27 // Only add column information if it is valid. | 27 // Only add column information if it is valid. |
| 28 columnInfo = " pos $_column"; | 28 columnInfo = " pos $_column"; |
| 29 } | 29 } |
| 30 return "'$_url': Failed assertion: line $_line$columnInfo: " | 30 return "'$_url': Failed assertion: line $_line$columnInfo: " |
| 31 "'$_failedAssertion' is not true."; | 31 "'$_failedAssertion' is not true."; |
| 32 } | 32 } |
| 33 final String _failedAssertion; | 33 final String _failedAssertion; |
| 34 final String _url; | 34 final String _url; |
| 35 final int _line; | 35 final int _line; |
| 36 final int _column; | 36 final int _column; |
| 37 } | 37 } |
| 38 | 38 |
| 39 patch class TypeError extends AssertionError { | 39 class _TypeError extends _AssertionError implements TypeError { |
| 40 TypeError._create(String url, int line, int column, | 40 _TypeError._create(String url, int line, int column, |
| 41 this._srcType, this._dstType, this._dstName, | 41 this._srcType, this._dstType, this._dstName, |
| 42 this._errorMsg) | 42 this._errorMsg) |
| 43 : super._create("is assignable", url, line, column); | 43 : super._create("is assignable", url, line, column); |
| 44 | 44 |
| 45 static _throwNew(int location, | 45 static _throwNew(int location, |
| 46 Object src_value, | 46 Object src_value, |
| 47 String dst_type_name, | 47 String dst_type_name, |
| 48 String dst_name, | 48 String dst_name, |
| 49 String error_msg) | 49 String error_msg) |
| 50 native "TypeError_throwNew"; | 50 native "TypeError_throwNew"; |
| 51 | 51 |
| 52 String toString() { | 52 String toString() { |
| 53 String str = (_errorMsg != null) ? _errorMsg : ""; | 53 String str = (_errorMsg != null) ? _errorMsg : ""; |
| 54 if ((_dstName != null) && (_dstName.length > 0)) { | 54 if ((_dstName != null) && (_dstName.length > 0)) { |
| 55 str = "${str}type '$_srcType' is not a subtype of " | 55 str = "${str}type '$_srcType' is not a subtype of " |
| 56 "type '$_dstType' of '$_dstName'."; | 56 "type '$_dstType' of '$_dstName'."; |
| 57 } else { | 57 } else { |
| 58 str = "${str}type error."; | 58 str = "${str}type error."; |
| 59 } | 59 } |
| 60 return str; | 60 return str; |
| 61 } | 61 } |
| 62 | 62 |
| 63 final String _srcType; | 63 final String _srcType; |
| 64 final String _dstType; | 64 final String _dstType; |
| 65 final String _dstName; | 65 final String _dstName; |
| 66 final String _errorMsg; | 66 final String _errorMsg; |
| 67 } | 67 } |
| 68 | 68 |
| 69 patch class CastError extends Error { | 69 class _CastError extends Error implements CastError { |
| 70 CastError._create(this._url, this._line, this._column, | 70 _CastError._create(this._url, this._line, this._column, |
| 71 this._srcType, this._dstType, this._dstName, | 71 this._srcType, this._dstType, this._dstName, |
| 72 this._errorMsg); | 72 this._errorMsg); |
| 73 | 73 |
| 74 // A CastError is allocated by TypeError._throwNew() when dst_name equals | 74 // A CastError is allocated by TypeError._throwNew() when dst_name equals |
| 75 // Exceptions::kCastErrorDstName. | 75 // Exceptions::kCastErrorDstName. |
| 76 | 76 |
| 77 String toString() { | 77 String toString() { |
| 78 String str = (_errorMsg != null) ? _errorMsg : ""; | 78 String str = (_errorMsg != null) ? _errorMsg : ""; |
| 79 str = "${str}type '$_srcType' is not a subtype of " | 79 str = "${str}type '$_srcType' is not a subtype of " |
| 80 "type '$_dstType' in type cast."; | 80 "type '$_dstType' in type cast."; |
| 81 return str; | 81 return str; |
| 82 } | 82 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 String toString() => "Javascript Integer Overflow: $_value"; | 337 String toString() => "Javascript Integer Overflow: $_value"; |
| 338 } | 338 } |
| 339 | 339 |
| 340 class _JavascriptCompatibilityError extends Error { | 340 class _JavascriptCompatibilityError extends Error { |
| 341 final String _msg; | 341 final String _msg; |
| 342 | 342 |
| 343 _JavascriptCompatibilityError(this._msg); | 343 _JavascriptCompatibilityError(this._msg); |
| 344 String toString() => "Javascript Compatibility Error: $_msg"; | 344 String toString() => "Javascript Compatibility Error: $_msg"; |
| 345 } | 345 } |
| 346 | 346 |
| OLD | NEW |