@@ -24,18 +24,39 @@ function ExceptionHandlerProvider($provide) {
2424}
2525
2626function exceptionHandler ( Raven , $delegate ) {
27- return function ( ex , cause ) {
27+ return function ( ex , cause ) {
2828 Raven . captureException ( ex , {
2929 extra : { cause : cause }
3030 } ) ;
3131 $delegate ( ex , cause ) ;
3232 } ;
3333}
3434
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+
3538Raven . addPlugin ( function ( ) {
3639 angular . module ( 'ngRaven' , [ ] )
3740 . provider ( 'Raven' , RavenProvider )
3841 . config ( [ '$provide' , ExceptionHandlerProvider ] ) ;
3942} ) ;
4043
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+
4162} ( typeof window !== 'undefined' ? window : this ) ) ;
0 commit comments