[CORD-967] Displaying correct error in the GUI

Change-Id: I28ecf2e7b301c4745e256a6e683f684fd4a72c4f
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);
     }
   };
 }