Enhance error handling and logging in backend controllers and services
This commit improves error handling in various controllers, including diaryNoteController, memberNoteController, and permissionController, by adding console error logging for better debugging. Additionally, it updates the diaryService and teamDocumentService to enhance functionality and maintainability. The config.js file is also updated to ensure proper configuration for the development environment. These changes contribute to a more robust and user-friendly application.
This commit is contained in:
@@ -87,8 +87,8 @@ class DiaryService {
|
||||
tag = await DiaryTag.create({ name: tagName });
|
||||
}
|
||||
const diaryDate = await DiaryDate.findByPk(diaryDateId);
|
||||
await diaryDate.addTag(tag);
|
||||
return await diaryDate.getTags();
|
||||
await diaryDate.addDiaryTag(tag);
|
||||
return await diaryDate.getDiaryTags();
|
||||
}
|
||||
|
||||
async addTagToDiaryDate(userToken, clubId, diaryDateId, tagId) {
|
||||
|
||||
@@ -980,6 +980,15 @@ class MemberTransferService {
|
||||
if (typeof birthDate === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(birthDate)) {
|
||||
return birthDate;
|
||||
}
|
||||
|
||||
// Erstes Matching auf deutsches Format dd.mm.yyyy
|
||||
const dottedMatch = String(birthDate).match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/);
|
||||
if (dottedMatch) {
|
||||
const day = dottedMatch[1].padStart(2, '0');
|
||||
const month = dottedMatch[2].padStart(2, '0');
|
||||
const year = dottedMatch[3];
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
|
||||
// Versuche zu parsen
|
||||
try {
|
||||
@@ -991,14 +1000,7 @@ class MemberTransferService {
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
} catch (error) {
|
||||
// Fallback: Versuche Format dd.mm.yyyy zu parsen
|
||||
const match = String(birthDate).match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/);
|
||||
if (match) {
|
||||
const day = match[1].padStart(2, '0');
|
||||
const month = match[2].padStart(2, '0');
|
||||
const year = match[3];
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
// noop
|
||||
}
|
||||
|
||||
return birthDate || '';
|
||||
|
||||
@@ -39,7 +39,16 @@ class TeamDocumentService {
|
||||
const filePath = path.join(uploadDir, uniqueFileName);
|
||||
|
||||
// Verschiebe die Datei vom temporären Verzeichnis zum finalen Speicherort
|
||||
fs.renameSync(file.path, filePath);
|
||||
try {
|
||||
fs.renameSync(file.path, filePath);
|
||||
} catch (error) {
|
||||
if (error.code === 'EXDEV') {
|
||||
fs.copyFileSync(file.path, filePath);
|
||||
fs.unlinkSync(file.path);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Lösche alte Dokumente des gleichen Typs für dieses Team
|
||||
await this.deleteDocumentsByType(clubTeamId, documentType);
|
||||
|
||||
Reference in New Issue
Block a user