File tree 2 files changed +25
-13
lines changed
test/unit/features/options
2 files changed +25
-13
lines changed Original file line number Diff line number Diff line change @@ -94,22 +94,23 @@ export default class Watcher {
94
94
pushTarget ( this )
95
95
let value
96
96
const vm = this . vm
97
- if ( this . user ) {
98
- try {
99
- value = this . getter . call ( vm , vm )
100
- } catch ( e ) {
97
+ try {
98
+ value = this . getter . call ( vm , vm )
99
+ } catch ( e ) {
100
+ if ( this . user ) {
101
101
handleError ( e , vm , `getter for watcher "${ this . expression } "` )
102
+ } else {
103
+ throw e
102
104
}
103
- } else {
104
- value = this . getter . call ( vm , vm )
105
- }
106
- // "touch" every property so they are all tracked as
107
- // dependencies for deep watching
108
- if ( this . deep ) {
109
- traverse ( value )
105
+ } finally {
106
+ // "touch" every property so they are all tracked as
107
+ // dependencies for deep watching
108
+ if ( this . deep ) {
109
+ traverse ( value )
110
+ }
111
+ popTarget ( )
112
+ this . cleanupDeps ( )
110
113
}
111
- popTarget ( )
112
- this . cleanupDeps ( )
113
114
return value
114
115
}
115
116
Original file line number Diff line number Diff line change @@ -193,4 +193,15 @@ describe('Options computed', () => {
193
193
} )
194
194
expect ( `computed property "a" is already defined as a prop` ) . toHaveBeenWarned ( )
195
195
} )
196
+
197
+ it ( 'rethrow computed error' , ( ) => {
198
+ const vm = new Vue ( {
199
+ computed : {
200
+ a : ( ) => {
201
+ throw new Error ( 'rethrow' )
202
+ }
203
+ }
204
+ } )
205
+ expect ( ( ) => vm . a ) . toThrowError ( 'rethrow' )
206
+ } )
196
207
} )
You can’t perform that action at this time.
0 commit comments