refs #1550. Improve error handling in ManageOrganizationalUnitComponent by parsing and cleaning error messages for better user feedback
testing/ogGui-multibranch/pipeline/head There was a failure building this commit Details

deb-pkg
Lucas Lara García 2025-02-24 12:50:27 +01:00
parent 56966fd767
commit f1ddf20d0c
2 changed files with 11 additions and 3 deletions

View File

@ -284,7 +284,11 @@ export class ManageOrganizationalUnitComponent implements OnInit {
},
error => {
console.error('Error al realizar PUT:', error);
this.toastService.error('Error al editar:', error);
const errorMessages = error.error['hydra:description'].split('\n');
errorMessages.forEach((message: string) => {
const cleanedMessage = message.replace(/networkSettings\.(\w+):/, 'Error $1:');
this.toastService.error(cleanedMessage);
});
}
);
} else {
@ -299,7 +303,11 @@ export class ManageOrganizationalUnitComponent implements OnInit {
},
error => {
console.error('Error al realizar POST:', error);
this.toastService.error('Error al crear:', error.error['hydra:description']);
const errorMessages = error.error['hydra:description'].split('\n');
errorMessages.forEach((message: string) => {
const cleanedMessage = message.replace(/networkSettings\.(\w+):/, 'Error $1:');
this.toastService.error(cleanedMessage);
});
}
);
}

View File

@ -56,7 +56,7 @@ body {
.ordinary-button {
background-color: #fafafa;
color: #5f5f5f;
color: #3d3d3d;
padding: 8px 18px;
border: 1px solid #5f5f5f;
border-radius: 4px;