From 294ef112442afead590c450d86cdb93536c16774 Mon Sep 17 00:00:00 2001 From: Dmatrushka19 Date: Wed, 29 Apr 2026 22:37:40 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B2=20auth/decorators.ts.=20=D0=94=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20AuthApi.getMe()?= =?UTF-8?q?=20=D0=BD=D1=83=D0=B6=D0=B5=D0=BD=20=D0=BE=D1=82=D0=B2=D0=B5?= =?UTF-8?q?=D1=82=20=D0=B2=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B5=20?= =?UTF-8?q?{=20data,=20error,=20response=20}=20=D0=B2=D0=BC=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=BE=20{response}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/controllers/auth/decorators.ts | 32 +++++++++++--------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/api/controllers/auth/decorators.ts b/src/api/controllers/auth/decorators.ts index 4899114..0690396 100644 --- a/src/api/controllers/auth/decorators.ts +++ b/src/api/controllers/auth/decorators.ts @@ -36,30 +36,26 @@ export function scoped( export function showErrorToast( method: F -): Func>, Parameters> { +): Func> | undefined>, Parameters> { return async (...args: any[]) => { const toastStore = useToastStore(); + try { - const { error, response } = await method(...args); - if (error) { - throw error; - } else { - return response; + const result = await method(...args); + + if (result?.error) { + throw result.error; } + + return result; } catch (err: any) { const error = err?.detail?.[0] ?? err; - if (error) { - toastStore.push({ - title: error.ru ?? error.msg ?? error, - type: ToastType.Error, - }); - } else { - toastStore.push({ - title: 'Неизвестная ошибка', - description: '', - type: ToastType.Error, - }); - } + + toastStore.push({ + title: error?.ru ?? error?.msg ?? error?.message ?? String(error), + type: ToastType.Error, + }); + return undefined; } }; From ec987885a7b2c3785752d6e0d28eaa01531ebe4b Mon Sep 17 00:00:00 2001 From: Dmatrushka19 Date: Wed, 29 Apr 2026 23:30:44 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BD=D1=83=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D1=83=D1=8E=20?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D1=83=20=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/controllers/auth/decorators.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/api/controllers/auth/decorators.ts b/src/api/controllers/auth/decorators.ts index 0690396..f77cb41 100644 --- a/src/api/controllers/auth/decorators.ts +++ b/src/api/controllers/auth/decorators.ts @@ -51,10 +51,18 @@ export function showErrorToast( } catch (err: any) { const error = err?.detail?.[0] ?? err; - toastStore.push({ - title: error?.ru ?? error?.msg ?? error?.message ?? String(error), - type: ToastType.Error, - }); + if (error) { + toastStore.push({ + title: error?.ru ?? error?.msg ?? error?.message ?? String(error), + type: ToastType.Error, + }); + } else { + toastStore.push({ + title: 'Неизвестная ошибка', + description: '', + type: ToastType.Error, + }); + } return undefined; }