fix error handling for 404 error in active time entry

This commit is contained in:
Gregor Vostrak
2024-04-29 12:38:59 +02:00
parent d0bc2edf5d
commit 77623f77e5

View File

@@ -57,6 +57,7 @@ export const useCurrentTimeEntryStore = defineStore('currentTimeEntry', () => {
async function fetchCurrentTimeEntry() { async function fetchCurrentTimeEntry() {
const organizationId = getCurrentOrganizationId(); const organizationId = getCurrentOrganizationId();
if (organizationId) { if (organizationId) {
try {
const timeEntriesResponse = await api.getMyActiveTimeEntry({}); const timeEntriesResponse = await api.getMyActiveTimeEntry({});
if (timeEntriesResponse?.data) { if (timeEntriesResponse?.data) {
if (timeEntriesResponse.data) { if (timeEntriesResponse.data) {
@@ -65,6 +66,9 @@ export const useCurrentTimeEntryStore = defineStore('currentTimeEntry', () => {
currentTimeEntry.value = { ...emptyTimeEntry }; currentTimeEntry.value = { ...emptyTimeEntry };
} }
} }
} catch (error) {
currentTimeEntry.value = { ...emptyTimeEntry };
}
} else { } else {
throw new Error( throw new Error(
'Failed to fetch current time entry because organization ID is missing.' 'Failed to fetch current time entry because organization ID is missing.'