From 2bbb30525ebf5af4da03f3ce9cb7fbbacbc2aa94 Mon Sep 17 00:00:00 2001 From: burakovec Date: Thu, 26 Mar 2026 12:38:43 +0300 Subject: [PATCH] Enhance error handling in useDataStore by adding skipErrorForStatuses option to bypass specific status codes in CheckApiError. This improves error management and allows for more flexible API response handling. --- src/stores/dataStore.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stores/dataStore.ts b/src/stores/dataStore.ts index f8f87b5..acdbc7e 100644 --- a/src/stores/dataStore.ts +++ b/src/stores/dataStore.ts @@ -64,6 +64,8 @@ export const useDataStore = defineStore('dataStore', () => { options?: Record toast?: Record full?: boolean + /** Bu status kodları için CheckApiError atlanır, hata objesi döner */ + skipErrorForStatuses?: number[] } = {} ): Promise => { try { @@ -86,7 +88,11 @@ export const useDataStore = defineStore('dataStore', () => { return response.data } } catch (error: any) { - CheckApiError(error.response?.status, error.response?.data) + const status = error.response?.status + if (data.skipErrorForStatuses?.includes(status)) { + return { _error: true, status, data: error.response?.data } + } + CheckApiError(status, error.response?.data) console.error('Hata oluştu:', error) return Promise.resolve('errorfalse') }