File tree 2 files changed +19
-13
lines changed
2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -22,22 +22,22 @@ function vuePlugin(Raven, Vue) {
22
22
23
23
var _oldOnError = Vue . config . errorHandler ;
24
24
Vue . config . errorHandler = function VueErrorHandler ( error , vm , info ) {
25
+ var metaData = { } ;
26
+
27
+ // vm and lifecycleHook are not always available
25
28
if ( Object . prototype . toString . call ( vm ) === '[object Object]' ) {
26
- var metaData = {
27
- componentName : formatComponentName ( vm ) ,
28
- propsData : vm . $options . propsData
29
- } ;
30
-
31
- // lifecycleHook is not always available
32
- if ( typeof info !== 'undefined' ) {
33
- metaData . lifecycleHook = info ;
34
- }
35
-
36
- Raven . captureException ( error , {
37
- extra : metaData
38
- } ) ;
29
+ metaData . componentName = formatComponentName ( vm ) ;
30
+ metaData . propsData = vm . $options . propsData ;
31
+ }
32
+
33
+ if ( arguments . length === 3 && typeof info !== 'undefined' ) {
34
+ metaData . lifecycleHook = info ;
39
35
}
40
36
37
+ Raven . captureException ( error , {
38
+ extra : metaData
39
+ } ) ;
40
+
41
41
if ( typeof _oldOnError === 'function' ) {
42
42
_oldOnError . call ( this , error , vm , info ) ;
43
43
}
Original file line number Diff line number Diff line change @@ -84,5 +84,11 @@ describe('Vue plugin', function() {
84
84
} . bind ( this )
85
85
) ;
86
86
} ) ;
87
+
88
+ it ( 'should still send a raw error when `vm` is not defined' , function ( ) {
89
+ vuePlugin ( Raven , this . MockVue ) ;
90
+ this . MockVue . config . errorHandler ( new Error ( 'foo' ) ) ;
91
+ assert . isTrue ( Raven . captureException . calledOnce ) ;
92
+ } ) ;
87
93
} ) ;
88
94
} ) ;
You can’t perform that action at this time.
0 commit comments