| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 class SubclassOfError extends Error {} | 5 class SubclassOfError extends Error {} |
| 6 | 6 |
| 7 fail() => throw "Fail"; | 7 fail() => throw "Fail"; |
| 8 | 8 |
| 9 // == Rethrow, skipping through typed handlers. == | 9 // == Rethrow, skipping through typed handlers. == |
| 10 | 10 |
| 11 aa1() { | 11 aa1() { |
| 12 try { | 12 try { |
| 13 bb1(); | 13 bb1(); |
| 14 fail(); | 14 fail(); |
| 15 } catch (error | 15 } catch(error |
| 16 , stacktrace // //# withtraceparameter: ok | 16 , stacktrace // //# withtraceparameter: ok |
| 17 ) { | 17 ) { |
| 18 expectTrace( | 18 expectTrace(['gg1', 'ff1', 'ee1', 'dd1', 'cc1', 'bb1', 'aa1'], error.stackTr
ace); |
| 19 ['gg1', 'ff1', 'ee1', 'dd1', 'cc1', 'bb1', 'aa1'], error.stackTrace); | |
| 20 expectTrace(['gg1', 'ff1', 'ee1', 'dd1', 'cc1', 'bb1', 'aa1'], stacktrace);
// //# withtraceparameter: continued | 19 expectTrace(['gg1', 'ff1', 'ee1', 'dd1', 'cc1', 'bb1', 'aa1'], stacktrace);
// //# withtraceparameter: continued |
| 21 } | 20 } |
| 22 } | 21 } |
| 23 | 22 |
| 24 bb1() => cc1(); | 23 bb1() => cc1(); |
| 25 | 24 |
| 26 cc1() { | 25 cc1() { |
| 27 try { | 26 try { |
| 28 dd1(); | 27 dd1(); |
| 29 } on String catch (e) { | 28 } on String catch(e) { |
| 30 fail(); | 29 fail(); |
| 31 } on int catch (e) { | 30 } on int catch(e) { |
| 32 fail(); | 31 fail(); |
| 33 } | 32 } |
| 34 } | 33 } |
| 35 | 34 |
| 36 dd1() => ee1(); | 35 dd1() => ee1(); |
| 37 | 36 |
| 38 ee1() { | 37 ee1() { |
| 39 try { | 38 try { |
| 40 ff1(); | 39 ff1(); |
| 41 } catch (e) { | 40 } catch(e) { |
| 42 rethrow; | 41 rethrow; |
| 43 } | 42 } |
| 44 } | 43 } |
| 45 | 44 |
| 46 ff1() => gg1(); | 45 ff1() => gg1(); |
| 47 | 46 |
| 48 gg1() => throw new SubclassOfError(); | 47 gg1() => throw new SubclassOfError(); |
| 49 | 48 |
| 50 // == Rethrow, rethrow again in typed handler. == | 49 // == Rethrow, rethrow again in typed handler. == |
| 51 | 50 |
| 52 aa2() { | 51 aa2() { |
| 53 try { | 52 try { |
| 54 bb2(); | 53 bb2(); |
| 55 fail(); | 54 fail(); |
| 56 } catch (error | 55 } catch(error |
| 57 , stacktrace // //# withtraceparameter: continued | 56 , stacktrace // //# withtraceparameter: continued |
| 58 ) { | 57 ) { |
| 59 expectTrace( | 58 expectTrace(['gg2', 'ff2', 'ee2', 'dd2', 'cc2', 'bb2', 'aa2'], error.stackTr
ace); |
| 60 ['gg2', 'ff2', 'ee2', 'dd2', 'cc2', 'bb2', 'aa2'], error.stackTrace); | |
| 61 expectTrace(['gg2', 'ff2', 'ee2', 'dd2', 'cc2', 'bb2', 'aa2'], stacktrace);
// //# withtraceparameter: continued | 59 expectTrace(['gg2', 'ff2', 'ee2', 'dd2', 'cc2', 'bb2', 'aa2'], stacktrace);
// //# withtraceparameter: continued |
| 62 } | 60 } |
| 63 } | 61 } |
| 64 | 62 |
| 65 bb2() => cc2(); | 63 bb2() => cc2(); |
| 66 | 64 |
| 67 cc2() { | 65 cc2() { |
| 68 try { | 66 try { |
| 69 dd2(); | 67 dd2(); |
| 70 } on SubclassOfError catch (e) { | 68 } on SubclassOfError catch(e) { |
| 71 rethrow; | 69 rethrow; |
| 72 } on int catch (e) { | 70 } on int catch(e) { |
| 73 fail(); | 71 fail(); |
| 74 } | 72 } |
| 75 } | 73 } |
| 76 | 74 |
| 77 dd2() => ee2(); | 75 dd2() => ee2(); |
| 78 | 76 |
| 79 ee2() { | 77 ee2() { |
| 80 try { | 78 try { |
| 81 ff2(); | 79 ff2(); |
| 82 } catch (e) { | 80 } catch(e) { |
| 83 rethrow; | 81 rethrow; |
| 84 } | 82 } |
| 85 } | 83 } |
| 86 | 84 |
| 87 ff2() => gg2(); | 85 ff2() => gg2(); |
| 88 | 86 |
| 89 gg2() => throw new SubclassOfError(); | 87 gg2() => throw new SubclassOfError(); |
| 90 | 88 |
| 91 // == Rethrow, with intervening catch without a trace parameter. | 89 // == Rethrow, with intervening catch without a trace parameter. |
| 92 | 90 |
| 93 aa3() { | 91 aa3() { |
| 94 try { | 92 try { |
| 95 bb3(); | 93 bb3(); |
| 96 fail(); | 94 fail(); |
| 97 } catch (error | 95 } catch(error |
| 98 , stacktrace // //# withtraceparameter: continued | 96 , stacktrace // //# withtraceparameter: continued |
| 99 ) { | 97 ) { |
| 100 expectTrace( | 98 expectTrace(['gg3', 'ff3', 'ee3', 'dd3', 'cc3', 'bb3', 'aa3'], error.stackTr
ace); |
| 101 ['gg3', 'ff3', 'ee3', 'dd3', 'cc3', 'bb3', 'aa3'], error.stackTrace); | |
| 102 expectTrace(['cc3', 'bb3', 'aa3'], stacktrace); // //# withtraceparameter: c
ontinued | 99 expectTrace(['cc3', 'bb3', 'aa3'], stacktrace); // //# withtraceparameter: c
ontinued |
| 103 } | 100 } |
| 104 } | 101 } |
| 105 | 102 |
| 106 bb3() => cc3(); | 103 bb3() => cc3(); |
| 107 | 104 |
| 108 cc3() { | 105 cc3() { |
| 109 try { | 106 try { |
| 110 dd3(); | 107 dd3(); |
| 111 } catch (e) { | 108 } catch(e) { |
| 112 throw e; | 109 throw e; |
| 113 } | 110 } |
| 114 } | 111 } |
| 115 | 112 |
| 116 dd3() => ee3(); | 113 dd3() => ee3(); |
| 117 | 114 |
| 118 ee3() { | 115 ee3() { |
| 119 try { | 116 try { |
| 120 ff3(); | 117 ff3(); |
| 121 } catch (e) { | 118 } catch(e) { |
| 122 rethrow; | 119 rethrow; |
| 123 } | 120 } |
| 124 } | 121 } |
| 125 | 122 |
| 126 ff3() => gg3(); | 123 ff3() => gg3(); |
| 127 | 124 |
| 128 gg3() => throw new SubclassOfError(); | 125 gg3() => throw new SubclassOfError(); |
| 129 | 126 |
| 130 expectTrace(functionNames, stacktrace) { | 127 expectTrace(functionNames, stacktrace) { |
| 131 // Note we don't expect functionNames to cover the whole trace, only the | 128 // Note we don't expect functionNames to cover the whole trace, only the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 148 actualIndex++; | 145 actualIndex++; |
| 149 expectedIndex++; | 146 expectedIndex++; |
| 150 } | 147 } |
| 151 } | 148 } |
| 152 } | 149 } |
| 153 | 150 |
| 154 main() { | 151 main() { |
| 155 aa1(); | 152 aa1(); |
| 156 aa2(); | 153 aa2(); |
| 157 aa3(); | 154 aa3(); |
| 158 } | 155 } |
| OLD | NEW |