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 // To suppress missing implicit constructor warnings. | |
48 factory DomException._() { throw new UnsupportedError("Not supported"); } | |
49 | |
50 static DomException internalCreateDomException() { | |
51 return new DomException._internalWrap(); | |
52 } | |
53 | |
54 js.JsObject blink_jsObject; | |
55 | |
56 factory DomException._internalWrap() { | |
57 return new DomException.internal_(); | |
58 } | |
59 | |
60 DomException.internal_() { } | |
61 | |
62 DomException.jsInterop(String m) { | |
63 var name_index = m.indexOf(': '); | |
64 if (name_index < 0) { | |
65 _name = ""; | |
66 _message = m; | |
67 } else { | |
68 _name = m.substring(0, name_index); | |
69 _message = m.substring(name_index + 1).trim(); | |
70 } | |
71 } | |
72 | |
73 @DomName('DOMException.message') | |
74 @DocsEditable() | |
75 String get message => _message; | |
76 | |
77 @DomName('DOMException.name') | |
78 @DocsEditable() | |
79 String get name => _name; | |
80 | |
81 @DomName('DOMException.toString') | |
82 @DocsEditable() | |
83 String toString() => "${_name}: $_message"; | |
84 | |
85 $else | |
86 $!MEMBERS | 43 $!MEMBERS |
87 $endif | |
88 $if DART2JS | 44 $if DART2JS |
89 @DomName('DOMException.toString') | 45 @DomName('DOMException.toString') |
90 @DocsEditable() | 46 @DocsEditable() |
91 String toString() => JS('String', 'String(#)', this); | 47 String toString() => JS('String', 'String(#)', this); |
92 $endif | 48 $endif |
93 } | 49 } |
OLD | NEW |