| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Native helpers generated by the compiler | 5 // Native helpers generated by the compiler |
| 6 // TODO(jmesserly): more natives should use this pattern | 6 // TODO(jmesserly): more natives should use this pattern |
| 7 | 7 |
| 8 // Translate a JavaScript exception to a Dart exception | 8 // Translate a JavaScript exception to a Dart exception |
| 9 // TODO(jmesserly): cross browser support. This is Chrome specific. | 9 // TODO(jmesserly): cross browser support. This is Chrome specific. |
| 10 _toDartException(e) native @""" | 10 _toDartException(e) native @""" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 dartEx.stack = stack; | 26 dartEx.stack = stack; |
| 27 return dartEx; | 27 return dartEx; |
| 28 } | 28 } |
| 29 | 29 |
| 30 if (e instanceof TypeError) { | 30 if (e instanceof TypeError) { |
| 31 switch(e.type) { | 31 switch(e.type) { |
| 32 case 'property_not_function': | 32 case 'property_not_function': |
| 33 case 'called_non_callable': | 33 case 'called_non_callable': |
| 34 if (e.arguments[0] == null) { | 34 if (e.arguments[0] == null) { |
| 35 return attachStack(new NullPointerException()); | 35 return attachStack(new NullPointerException(null, [])); |
| 36 } else { | 36 } else { |
| 37 return attachStack(new ObjectNotClosureException()); | 37 return attachStack(new ObjectNotClosureException()); |
| 38 } | 38 } |
| 39 break; | 39 break; |
| 40 case 'non_object_property_call': | 40 case 'non_object_property_call': |
| 41 case 'non_object_property_load': | 41 case 'non_object_property_load': |
| 42 return attachStack(new NullPointerException()); | 42 return attachStack(new NullPointerException(null, [])); |
| 43 break; | 43 break; |
| 44 case 'undefined_method': | 44 case 'undefined_method': |
| 45 var mname = e.arguments[0]; | 45 var mname = e.arguments[0]; |
| 46 if (typeof(mname) == 'string' && (mname.indexOf('call$') == 0 | 46 if (typeof(mname) == 'string' && (mname.indexOf('call$') == 0 |
| 47 || mname == 'call' || mname == 'apply')) { | 47 || mname == 'call' || mname == 'apply')) { |
| 48 return attachStack(new ObjectNotClosureException()); | 48 return attachStack(new ObjectNotClosureException()); |
| 49 } else { | 49 } else { |
| 50 // TODO(jmesserly): fix noSuchMethod on operators so we don't hit this | 50 // TODO(jmesserly): fix noSuchMethod on operators so we don't hit this |
| 51 return attachStack(new NoSuchMethodException('', e.arguments[0], [])); | 51 return attachStack(new NoSuchMethodException('', e.arguments[0], [])); |
| 52 } | 52 } |
| 53 break; | 53 break; |
| 54 } | 54 } |
| 55 } else if (e instanceof RangeError) { | 55 } else if (e instanceof RangeError) { |
| 56 if (e.message.indexOf('call stack') >= 0) { | 56 if (e.message.indexOf('call stack') >= 0) { |
| 57 return attachStack(new StackOverflowException()); | 57 return attachStack(new StackOverflowException()); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 return e;""" { | 60 return e;""" { |
| 61 // Ensure constructors are generated | 61 // Ensure constructors are generated |
| 62 new ObjectNotClosureException(); | 62 new ObjectNotClosureException(); |
| 63 new NullPointerException(); | 63 new NullPointerException(null, null); |
| 64 new NoSuchMethodException(null, null, null); | 64 new NoSuchMethodException(null, null, null); |
| 65 new StackOverflowException(); | 65 new StackOverflowException(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // TODO(jmesserly): we shouldn't be relying on the e.stack property. | 68 // TODO(jmesserly): we shouldn't be relying on the e.stack property. |
| 69 // Need to mangle it. | 69 // Need to mangle it. |
| 70 _stackTraceOf(e) native @"return (e && e.stack) ? e.stack : null;"; | 70 _stackTraceOf(e) native @"return (e && e.stack) ? e.stack : null;"; |
| OLD | NEW |