Merge "[CORD-967] Displaying correct error in the GUI"
diff --git a/src/app/core/services/helpers/config.helpers.ts b/src/app/core/services/helpers/config.helpers.ts
index 1cd9e60..c495ba5 100644
--- a/src/app/core/services/helpers/config.helpers.ts
+++ b/src/app/core/services/helpers/config.helpers.ts
@@ -269,10 +269,6 @@
 
       item.$save()
         .then((res) => {
-          if (res.status === 403 || res.status === 405 || res.status === 404 || res.status === 500) {
-            // TODO understand why 405 does not go directly in catch (it may be related to ng-rest-gw)
-            throw new Error();
-          }
           formCfg.feedback = {
             show: true,
             message: `${model.name} succesfully saved`,
@@ -282,8 +278,13 @@
           this.toastr.success(`${model.name} succesfully saved`);
         })
         .catch(err => {
-          // TODO keep the edited model
-          this.toastr.error(`Error while saving ${model.name}`);
+          formCfg.feedback = {
+            show: true,
+            message: `Error while saving ${model.name}: ${err.error}. ${err.specific_error || ''}`,
+            type: 'danger',
+            closeBtn: true
+          };
+          this.toastr.error(err.specific_error || '', `Error while saving ${model.name}: ${err.error}`);
         });
     };
 
diff --git a/src/interceptors.ts b/src/interceptors.ts
index 8a11d08..a1b5df8 100644
--- a/src/interceptors.ts
+++ b/src/interceptors.ts
@@ -11,17 +11,16 @@
     switch (res.status) {
       case -1:
       case 401:
-      case 500:
         $cookies.remove('sessionid', {path: '/'});
         $state.go('login');
         return $q.reject(res);
       default:
-        return res;
+        return $q.reject(res);
     }
   };
 
   return {
-    response: checkLogin,
+    // response: checkLogin,
     responseError: checkLogin
   };
 }
@@ -39,7 +38,7 @@
   };
 }
 
-export function NoHyperlinksInterceptor() {
+export function NoHyperlinksInterceptor($q: ng.IQService) {
   return {
     request: (req) => {
       if (req.url.indexOf('.html') === -1) {
@@ -68,6 +67,9 @@
         res.data = res.data;
       }
       return res;
+    },
+    responseError: (res) => {
+      return $q.reject(res.data);
     }
   };
 }
diff --git a/typings.json b/typings.json
index a830275..709ff96 100644
--- a/typings.json
+++ b/typings.json
@@ -5,11 +5,12 @@
     "angular-mocks": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-mocks.d.ts#dc9dabe74a5be62613b17a3605309783a12ff28a",
     "angular-resource": "registry:dt/angular-resource#1.5.0+20161114123626",
     "angular-ui-router": "registry:dt/angular-ui-router#1.1.5+20160707113237",
-    "es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504",
+    "es6-shim": "registry:dt/es6-shim#0.31.2+20160726072212",
     "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#dc9dabe74a5be62613b17a3605309783a12ff28a",
     "jasmine-jquery": "registry:dt/jasmine-jquery#1.5.8+20161128184045",
     "jquery": "registry:dt/jquery#1.10.0+20161119044246",
     "require": "registry:dt/require#2.1.20+20160316155526",
+    "rx": "npm:rx/ts/rx.all.d.ts",
     "socket.io-client": "registry:dt/socket.io-client#1.4.4+20160317120654"
   },
   "dependencies": {