File tree Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Expand file tree Collapse file tree 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) {
2222
2323 var _oldOnError = Vue . config . errorHandler ;
2424 Vue . config . errorHandler = function VueErrorHandler ( error , vm , info ) {
25+ var metaData = { } ;
26+
27+ // vm and lifecycleHook are not always available
2528 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 ( typeof info !== 'undefined' ) {
34+ metaData . lifecycleHook = info ;
3935 }
4036
37+ Raven . captureException ( error , {
38+ extra : metaData
39+ } ) ;
40+
4141 if ( typeof _oldOnError === 'function' ) {
4242 _oldOnError . call ( this , error , vm , info ) ;
4343 }
Original file line number Diff line number Diff line change @@ -84,5 +84,11 @@ describe('Vue plugin', function() {
8484 } . bind ( this )
8585 ) ;
8686 } ) ;
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+ } ) ;
8793 } ) ;
8894} ) ;
You can’t perform that action at this time.
0 commit comments