OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
6 | 6 |
7 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ | 7 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ |
8 | 8 |
9 static const String INDEX_SIZE = 'IndexSizeError'; | 9 static const String INDEX_SIZE = 'IndexSizeError'; |
10 static const String HIERARCHY_REQUEST = 'HierarchyRequestError'; | 10 static const String HIERARCHY_REQUEST = 'HierarchyRequestError'; |
(...skipping 22 matching lines...) Expand all Loading... |
33 var errorName = JS('String', '#.name', this); | 33 var errorName = JS('String', '#.name', this); |
34 // Although Safari nightly has updated the name to SecurityError, Safari 5 | 34 // Although Safari nightly has updated the name to SecurityError, Safari 5 |
35 // and 6 still return SECURITY_ERR. | 35 // and 6 still return SECURITY_ERR. |
36 if (Device.isWebKit && errorName == 'SECURITY_ERR') return 'SecurityError'; | 36 if (Device.isWebKit && errorName == 'SECURITY_ERR') return 'SecurityError'; |
37 // Chrome release still uses old string, remove this line when Chrome stable | 37 // Chrome release still uses old string, remove this line when Chrome stable |
38 // also prints out SyntaxError. | 38 // also prints out SyntaxError. |
39 if (Device.isWebKit && errorName == 'SYNTAX_ERR') return 'SyntaxError'; | 39 if (Device.isWebKit && errorName == 'SYNTAX_ERR') return 'SyntaxError'; |
40 return errorName; | 40 return errorName; |
41 } | 41 } |
42 $endif | 42 $endif |
| 43 $if JSINTEROP |
| 44 String _name; |
| 45 String _message; |
| 46 |
| 47 DomException.jsInterop(String m) { |
| 48 var name_index = m.indexOf(': '); |
| 49 if (name_index < 0) { |
| 50 _name = ""; |
| 51 _message = m; |
| 52 } else { |
| 53 _name = m.substring(0, name_index); |
| 54 _message = m.substring(name_index + 1).trim(); |
| 55 } |
| 56 } |
| 57 |
| 58 @DomName('DOMException.message') |
| 59 @DocsEditable() |
| 60 String get message => _message; |
| 61 |
| 62 @DomName('DOMException.name') |
| 63 @DocsEditable() |
| 64 String get name => _name; |
| 65 |
| 66 @DomName('DOMException.toString') |
| 67 @DocsEditable() |
| 68 String toString() => "${_name}: $_message"; |
| 69 |
| 70 $else |
43 $!MEMBERS | 71 $!MEMBERS |
| 72 $endif |
44 $if DART2JS | 73 $if DART2JS |
45 @DomName('DOMException.toString') | 74 @DomName('DOMException.toString') |
46 @DocsEditable() | 75 @DocsEditable() |
47 String toString() => JS('String', 'String(#)', this); | 76 String toString() => JS('String', 'String(#)', this); |
48 $endif | 77 $endif |
49 } | 78 } |
OLD | NEW |