[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}`);
});
};