@@ -12,33 +12,30 @@ var angular = window.angular,
1212// quit if angular isn't on the page
1313if ( ! ( angular && Raven ) ) return ;
1414
15- // Angular plugin doesn't go through the normal `Raven.addPlugin`
16- // since this bootstraps the `install()` automatically.
17-
18- function ngRavenProvider ( $provide ) {
19- $provide . decorator ( '$exceptionHandler' , [
20- 'RavenConfig' , '$delegate' ,
21- ngRavenExceptionHandler
22- ] ) ;
15+ function RavenProvider ( ) {
16+ this . $get = [ '$window' , function ( $window , $log ) {
17+ return $window . Raven ;
18+ } ] ;
2319}
2420
25- function ngRavenExceptionHandler ( RavenConfig , $delegate ) {
26- if ( ! RavenConfig )
27- throw new Error ( 'RavenConfig must be set before using this' ) ;
28-
29- if ( RavenConfig . debug !== void 0 ) {
30- Raven . debug = RavenConfig . debug ;
31- }
21+ function ExceptionHandlerProvider ( $provide ) {
22+ $provide . decorator ( '$exceptionHandler' ,
23+ [ 'Raven' , '$delegate' , exceptionHandler ] ) ;
24+ }
3225
33- Raven . config ( RavenConfig . dsn , RavenConfig . config ) . install ( ) ;
34- return function angularExceptionHandler ( ex , cause ) {
26+ function exceptionHandler ( Raven , $delegate ) {
27+ return function ( ex , cause ) {
28+ Raven . captureException ( ex , {
29+ extra : { cause : cause }
30+ } ) ;
3531 $delegate ( ex , cause ) ;
36- Raven . captureException ( ex , { extra : { cause : cause } } ) ;
3732 } ;
3833}
3934
40- angular . module ( 'ngRaven' , [ ] )
41- . config ( [ '$provide' , ngRavenProvider ] )
42- . value ( 'Raven' , Raven ) ;
35+ Raven . addPlugin ( function ( ) {
36+ angular . module ( 'ngRaven' , [ ] )
37+ . provider ( 'Raven' , RavenProvider )
38+ . config ( [ '$provide' , ExceptionHandlerProvider ] ) ;
39+ } ) ;
4340
4441} ( typeof window !== 'undefined' ? window : this ) ) ;
0 commit comments