refactor(storage): drop unreachable try/catch in getDutiesForMonth
new Date() and the object spread never throw; the isNaN guard already drops invalid dates via the .filter(). The inner catch could never fire. Outer boundary try/catch is kept. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
91565741a8
commit
7efdcbe17b
1 changed files with 4 additions and 12 deletions
16
storage.js
16
storage.js
|
|
@ -141,20 +141,12 @@ class DataStorage {
|
|||
|
||||
// Convert date strings back to Date objects
|
||||
return allDuties[employeeName][monthKey].map(duty => {
|
||||
try {
|
||||
const dateObj = new Date(duty.date);
|
||||
if (isNaN(dateObj.getTime())) {
|
||||
console.error(`Fehler: Ungültiges Datum für Dienst: ${duty.date}`);
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
...duty,
|
||||
date: dateObj
|
||||
};
|
||||
} catch (e) {
|
||||
console.error('Fehler beim Konvertieren des Datums:', e);
|
||||
const dateObj = new Date(duty.date);
|
||||
if (isNaN(dateObj.getTime())) {
|
||||
console.error(`Fehler: Ungültiges Datum für Dienst: ${duty.date}`);
|
||||
return null;
|
||||
}
|
||||
return { ...duty, date: dateObj };
|
||||
}).filter(duty => duty !== null); // Filter out invalid entries
|
||||
} catch (e) {
|
||||
console.error('Fehler beim Laden der Dienste für Monat:', e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue