Update training group management and enhance UI components
This commit introduces the `TrainingGroup` model and related functionality, allowing for the management of training groups within the application. The `ClubService` is updated to automatically create preset groups upon club creation. The frontend is enhanced with new views and components, including `TrainingGroupsView` and `TrainingGroupsTab`, to facilitate the display and management of training groups. Additionally, the `MembersView` is updated to allow adding and removing members from training groups, improving the overall user experience and interactivity in managing club members and their associated training groups.
This commit is contained in:
33
backend/utils/errorUtils.js
Normal file
33
backend/utils/errorUtils.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Gibt eine sichere Fehlermeldung zurück, die an den Client gesendet werden kann.
|
||||
* Verhindert, dass sensible Informationen (wie Stack-Traces oder interne Details) nach außen gelangen.
|
||||
*
|
||||
* @param {Error} error - Der Fehler-Objekt
|
||||
* @param {string} defaultMessage - Standard-Nachricht, die verwendet wird, wenn keine sichere Nachricht verfügbar ist
|
||||
* @returns {string} - Sichere Fehlermeldung
|
||||
*/
|
||||
export function getSafeErrorMessage(error, defaultMessage = 'Ein Fehler ist aufgetreten') {
|
||||
// Wenn kein Fehler vorhanden ist, gib die Standard-Nachricht zurück
|
||||
if (!error) {
|
||||
return defaultMessage;
|
||||
}
|
||||
|
||||
// Wenn der Fehler eine message hat und es keine interne/technische Nachricht ist
|
||||
if (error.message) {
|
||||
const message = error.message;
|
||||
|
||||
// Prüfe, ob die Nachricht sicher ist (keine Stack-Traces, keine internen Pfade, etc.)
|
||||
// Erlaube nur benutzerfreundliche Nachrichten
|
||||
if (message &&
|
||||
!message.includes('at ') && // Keine Stack-Traces
|
||||
!message.includes('Error:') && // Keine technischen Fehler-Präfixe
|
||||
!message.startsWith('/') && // Keine Dateipfade
|
||||
message.length < 500) { // Keine sehr langen Nachrichten (könnten Stack-Traces sein)
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: Standard-Nachricht verwenden
|
||||
return defaultMessage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user