File tree 2 files changed +23
-12
lines changed
2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -22,20 +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
- componentName : formatComponentName ( vm ) ,
27
- propsData : vm . $options . propsData
28
- } ;
29
-
30
- // lifecycleHook is not always available
31
- if ( typeof info !== 'undefined' ) {
32
- metaData . lifecycleHook = info ;
25
+ 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
+ } ) ;
33
39
}
34
40
35
- Raven . captureException ( error , {
36
- extra : metaData
37
- } ) ;
38
-
39
41
if ( typeof _oldOnError === 'function' ) {
40
42
_oldOnError . call ( this , error , vm , info ) ;
41
43
}
Original file line number Diff line number Diff line change @@ -75,5 +75,14 @@ describe('Vue plugin', function() {
75
75
lifecycleHook : 'mounted'
76
76
} ) ;
77
77
} ) ;
78
+
79
+ it ( 'should not explode when `vm` is not defined' , function ( ) {
80
+ vuePlugin ( Raven , this . MockVue ) ;
81
+ assert . doesNotThrow (
82
+ function ( ) {
83
+ this . MockVue . config . errorHandler ( new Error ( 'foo' ) ) ;
84
+ } . bind ( this )
85
+ ) ;
86
+ } ) ;
78
87
} ) ;
79
88
} ) ;
You can’t perform that action at this time.
0 commit comments