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 | |
62 class IllegalJSRegExpException implements Exception { | 43 class IllegalJSRegExpException implements Exception { |
63 const IllegalJSRegExpException(String this._pattern, String this._errmsg); | 44 const IllegalJSRegExpException(String this._pattern, String this._errmsg); |
64 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'"; | 45 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'"; |
65 final String _pattern; | 46 final String _pattern; |
66 final String _errmsg; | 47 final String _errmsg; |
67 } | 48 } |
68 | 49 |
69 | 50 |
70 class IntegerDivisionByZeroException implements Exception { | 51 class IntegerDivisionByZeroException implements Exception { |
71 const IntegerDivisionByZeroException(); | 52 const IntegerDivisionByZeroException(); |
72 String toString() => "IntegerDivisionByZeroException"; | 53 String toString() => "IntegerDivisionByZeroException"; |
73 } | 54 } |
74 | 55 |
75 /** | 56 /** |
76 * Exception thrown when a runtime error occurs. | 57 * Exception thrown when a runtime error occurs. |
77 */ | 58 */ |
78 class RuntimeError implements Exception { | 59 class RuntimeError implements Exception { |
79 final message; | 60 final message; |
80 RuntimeError(this.message); | 61 RuntimeError(this.message); |
81 String toString() => "RuntimeError: $message"; | 62 String toString() => "RuntimeError: $message"; |
82 } | 63 } |
OLD | NEW |