File tree 3 files changed +25
-16
lines changed
3 files changed +25
-16
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,13 @@ module.exports = {
4
4
console . warn ( '@deveodk/vue-error-tracker : axios must be set before this plugin is used.' )
5
5
}
6
6
} ,
7
- _interceptor : function ( Vue , code ) {
7
+ _interceptor : function ( Vue , code , errorCb ) {
8
8
Vue . prototype . axios . interceptors . response . use ( function ( response ) {
9
9
// Do something with response data
10
10
code ( response )
11
11
return response
12
12
} , function ( error ) {
13
+ errorCb ( error )
13
14
// Do something with response error
14
15
return error
15
16
} )
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @deveodk/vue-error-tracker" ,
3
- "version" : " 1.0.1 " ,
3
+ "version" : " 1.0.2 " ,
4
4
"description" : " Give your users an easy way to see when something in your application goes wrong. This package makes it easy to show error messages." ,
5
5
"author" :
" Jason Kelly <[email protected] >" ,
6
6
"main" : " dist/@deveodk/vue-error-tracker.common.js" ,
Original file line number Diff line number Diff line change @@ -16,27 +16,35 @@ function plugin (Vue, options) {
16
16
if ( ! response ) {
17
17
return
18
18
}
19
- const length = Object . keys ( options . HttpErrorCodes ) . length
20
- let temp
21
- let object
22
- for ( let i = 0 ; i < length ; i ++ ) {
23
- temp = Object . keys ( options . HttpErrorCodes ) [ i ]
24
- object = options . HttpErrorCodes [ temp ]
25
- if ( response . status === parseInt ( temp ) ) {
26
- if ( notification ) {
27
- switch ( object . type ) {
28
- case 'success' :
19
+ trackErrors ( response )
20
+ } , ( error ) => {
21
+ if ( ! error ) {
22
+ return
23
+ }
24
+ trackErrors ( error )
25
+ } )
26
+ }
27
+ function trackErrors ( response ) {
28
+ const length = Object . keys ( options . HttpErrorCodes ) . length
29
+ let temp
30
+ let object
31
+ for ( let i = 0 ; i < length ; i ++ ) {
32
+ temp = Object . keys ( options . HttpErrorCodes ) [ i ]
33
+ object = options . HttpErrorCodes [ temp ]
34
+ if ( response . status === parseInt ( temp ) ) {
35
+ if ( notification ) {
36
+ switch ( object . type ) {
37
+ case 'success' :
29
38
options . NotificationDriver . _notifySuccess ( Vue , object . message , object . title )
30
39
break
31
- case 'error' :
40
+ case 'error' :
32
41
options . NotificationDriver . _notifyError ( Vue , object . message , object . title )
33
42
break
34
- }
35
43
}
36
- return
37
44
}
45
+ return
38
46
}
39
- } )
47
+ }
40
48
}
41
49
}
42
50
You can’t perform that action at this time.
0 commit comments