@@ -24,18 +24,39 @@ function ExceptionHandlerProvider($provide) {
24
24
}
25
25
26
26
function exceptionHandler ( Raven , $delegate ) {
27
- return function ( ex , cause ) {
27
+ return function ( ex , cause ) {
28
28
Raven . captureException ( ex , {
29
29
extra : { cause : cause }
30
30
} ) ;
31
31
$delegate ( ex , cause ) ;
32
32
} ;
33
33
}
34
34
35
+ // See https://github.com/angular/angular.js/blob/v1.4.7/src/minErr.js
36
+ var angularPattern = / ^ \[ ( (?: [ $ a - z A - Z 0 - 9 ] + : ) ? (?: [ $ a - z A - Z 0 - 9 ] + ) ) \] ( .+ ?) \n ( \S + ) $ / ;
37
+
35
38
Raven . addPlugin ( function ( ) {
36
39
angular . module ( 'ngRaven' , [ ] )
37
40
. provider ( 'Raven' , RavenProvider )
38
41
. config ( [ '$provide' , ExceptionHandlerProvider ] ) ;
39
42
} ) ;
40
43
44
+ Raven . setDataCallback ( function ( data ) {
45
+ // We only care about mutating an exception
46
+ var exception = data . exception ;
47
+ if ( exception ) {
48
+ exception = exception . values [ 0 ] ;
49
+ var matches = angularPattern . exec ( exception . value ) ;
50
+
51
+ if ( matches ) {
52
+ // This type now becomes something like: $rootScope:inprog
53
+ exception . type = matches [ 1 ] ;
54
+ exception . value = matches [ 2 ] ;
55
+ data . message = exception . type + ': ' + exception . value ;
56
+ // auto set a new tag specifically for the angular error url
57
+ data . extra . angularDocs = matches [ 3 ] . substr ( 0 , 250 ) ;
58
+ }
59
+ }
60
+ } ) ;
61
+
41
62
} ( typeof window !== 'undefined' ? window : this ) ) ;
0 commit comments