| 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 // Exceptions are thrown either by the VM or from Dart code. | 5 // Exceptions are thrown either by the VM or from Dart code. |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Interface implemented by all core library exceptions. | 8 * Interface implemented by all core library exceptions. |
| 9 * Defaults to an implementation that only carries a simple message. | 9 * Defaults to an implementation that only carries a simple message. |
| 10 */ | 10 */ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * Creates a new FormatException with an optional error [message]. | 35 * Creates a new FormatException with an optional error [message]. |
| 36 */ | 36 */ |
| 37 const FormatException([this.message = ""]); | 37 const FormatException([this.message = ""]); |
| 38 | 38 |
| 39 String toString() => "FormatException: $message"; | 39 String toString() => "FormatException: $message"; |
| 40 } | 40 } |
| 41 | 41 |
| 42 | 42 |
| 43 class NullPointerException implements Exception { |
| 44 const NullPointerException([this.functionName, this.arguments = const []]); |
| 45 String toString() { |
| 46 if (functionName == null) { |
| 47 return exceptionName; |
| 48 } else { |
| 49 return "$exceptionName : method: '$functionName'\n" |
| 50 "Receiver: null\n" |
| 51 "Arguments: $arguments"; |
| 52 } |
| 53 } |
| 54 |
| 55 String get exceptionName => "NullPointerException"; |
| 56 |
| 57 final String functionName; |
| 58 final List arguments; |
| 59 } |
| 60 |
| 61 |
| 43 class IllegalJSRegExpException implements Exception { | 62 class IllegalJSRegExpException implements Exception { |
| 44 const IllegalJSRegExpException(String this._pattern, String this._errmsg); | 63 const IllegalJSRegExpException(String this._pattern, String this._errmsg); |
| 45 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'"; | 64 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'"; |
| 46 final String _pattern; | 65 final String _pattern; |
| 47 final String _errmsg; | 66 final String _errmsg; |
| 48 } | 67 } |
| 49 | 68 |
| 50 | 69 |
| 51 class IntegerDivisionByZeroException implements Exception { | 70 class IntegerDivisionByZeroException implements Exception { |
| 52 const IntegerDivisionByZeroException(); | 71 const IntegerDivisionByZeroException(); |
| 53 String toString() => "IntegerDivisionByZeroException"; | 72 String toString() => "IntegerDivisionByZeroException"; |
| 54 } | 73 } |
| 55 | 74 |
| 56 /** | 75 /** |
| 57 * Exception thrown when a runtime error occurs. | 76 * Exception thrown when a runtime error occurs. |
| 58 */ | 77 */ |
| 59 class RuntimeError implements Exception { | 78 class RuntimeError implements Exception { |
| 60 final message; | 79 final message; |
| 61 RuntimeError(this.message); | 80 RuntimeError(this.message); |
| 62 String toString() => "RuntimeError: $message"; | 81 String toString() => "RuntimeError: $message"; |
| 63 } | 82 } |
| OLD | NEW |