diff --git a/src/api/controllers/auth/decorators.ts b/src/api/controllers/auth/decorators.ts index 4899114..f77cb41 100644 --- a/src/api/controllers/auth/decorators.ts +++ b/src/api/controllers/auth/decorators.ts @@ -36,21 +36,24 @@ 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, + title: error?.ru ?? error?.msg ?? error?.message ?? String(error), type: ToastType.Error, }); } else { @@ -60,6 +63,7 @@ export function showErrorToast( type: ToastType.Error, }); } + return undefined; } };