File tree Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Expand file tree Collapse file tree 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) {
2222
2323 var _oldOnError = Vue . config . errorHandler ;
2424 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+ } ) ;
3339 }
3440
35- Raven . captureException ( error , {
36- extra : metaData
37- } ) ;
38-
3941 if ( typeof _oldOnError === 'function' ) {
4042 _oldOnError . call ( this , error , vm , info ) ;
4143 }
Original file line number Diff line number Diff line change @@ -75,5 +75,14 @@ describe('Vue plugin', function() {
7575 lifecycleHook : 'mounted'
7676 } ) ;
7777 } ) ;
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+ } ) ;
7887 } ) ;
7988} ) ;
You can’t perform that action at this time.
0 commit comments