blob: 4af368054939f921fc48c2d9e15ab9d04ca2ed05 [file] [log] [blame]
Matteo Scandolo889ced32015-11-04 16:07:09 +01001(function() {
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -07002 'use strict';
Matteo Scandolo45a5c562016-04-13 16:20:13 -07003
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -07004 angular.module('bugSnag', []).factory('$exceptionHandler', function () {
5 return function (exception, cause) {
6 if( window.Bugsnag ){
7 Bugsnag.notifyException(exception, {diagnostics: {cause: cause}});
8 }
9 else{
10 console.error(exception, cause, exception.stack);
11 }
12 };
13 });
Matteo Scandolo32f83922016-02-11 09:35:29 -080014
Matteo Scandolo45a5c562016-04-13 16:20:13 -070015 /**
16 * @ngdoc overview
17 * @name xos.helpers
18 * @description this is the module that group all the helpers service and components for XOS
19 **/
20
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -070021 angular
22 .module('xos.helpers', [
23 'ngCookies',
24 'ngResource',
Matteo Scandoloc88bb9f2016-04-25 10:31:22 -070025 'ngAnimate',
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -070026 'bugSnag',
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070027 'xos.uiComponents',
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -070028 ])
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070029 .config(config)
Matteo Scandolo741d6b42016-05-25 16:02:16 -070030
31 /**
32 * @ngdoc service
33 * @name xos.helpers._
34 * @description Wrap [lodash](https://lodash.com/docs) in an Angular Service
35 **/
36
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070037 .factory('_', $window => $window._ );
Matteo Scandolo889ced32015-11-04 16:07:09 +010038
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -070039 function config($httpProvider, $interpolateProvider, $resourceProvider) {
40 $httpProvider.interceptors.push('SetCSRFToken');
Matteo Scandolo889ced32015-11-04 16:07:09 +010041
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -070042 $interpolateProvider.startSymbol('{$');
43 $interpolateProvider.endSymbol('$}');
Matteo Scandolo889ced32015-11-04 16:07:09 +010044
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -070045 // NOTE http://www.masnun.com/2013/09/18/django-rest-framework-angularjs-resource-trailing-slash-problem.html
46 $resourceProvider.defaults.stripTrailingSlashes = false;
47 }
Matteo Scandolo889ced32015-11-04 16:07:09 +010048})();