| 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 * A marker interface implemented by all core library exceptions. | 8 * A marker interface implemented by all core library exceptions. |
| 9 * | 9 * |
| 10 * An [Exception] is intended to convey information to the user about a failure, | 10 * An [Exception] is intended to convey information to the user about a failure, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * Creates a new FormatException with an optional error [message]. | 47 * Creates a new FormatException with an optional error [message]. |
| 48 */ | 48 */ |
| 49 const FormatException([this.message = ""]); | 49 const FormatException([this.message = ""]); |
| 50 | 50 |
| 51 String toString() => "FormatException: $message"; | 51 String toString() => "FormatException: $message"; |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 class NullPointerException implements Exception { | |
| 56 const NullPointerException([this.functionName, this.arguments = const []]); | |
| 57 String toString() { | |
| 58 if (functionName == null) { | |
| 59 return exceptionName; | |
| 60 } else { | |
| 61 return "$exceptionName : method: '$functionName'\n" | |
| 62 "Receiver: null\n" | |
| 63 "Arguments: $arguments"; | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 String get exceptionName => "NullPointerException"; | |
| 68 | |
| 69 final String functionName; | |
| 70 final List arguments; | |
| 71 } | |
| 72 | |
| 73 | |
| 74 class IllegalJSRegExpException implements Exception { | 55 class IllegalJSRegExpException implements Exception { |
| 75 const IllegalJSRegExpException(String this._pattern, String this._errmsg); | 56 const IllegalJSRegExpException(String this._pattern, String this._errmsg); |
| 76 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'"; | 57 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'"; |
| 77 final String _pattern; | 58 final String _pattern; |
| 78 final String _errmsg; | 59 final String _errmsg; |
| 79 } | 60 } |
| 80 | 61 |
| 81 | 62 |
| 82 class IntegerDivisionByZeroException implements Exception { | 63 class IntegerDivisionByZeroException implements Exception { |
| 83 const IntegerDivisionByZeroException(); | 64 const IntegerDivisionByZeroException(); |
| 84 String toString() => "IntegerDivisionByZeroException"; | 65 String toString() => "IntegerDivisionByZeroException"; |
| 85 } | 66 } |
| 86 | 67 |
| 87 /** | 68 /** |
| 88 * Exception thrown when a runtime error occurs. | 69 * Exception thrown when a runtime error occurs. |
| 89 */ | 70 */ |
| 90 class RuntimeError implements Exception { | 71 class RuntimeError implements Exception { |
| 91 final message; | 72 final message; |
| 92 RuntimeError(this.message); | 73 RuntimeError(this.message); |
| 93 String toString() => "RuntimeError: $message"; | 74 String toString() => "RuntimeError: $message"; |
| 94 } | 75 } |
| OLD | NEW |