фикс отсутствия ошибки при регистрации с невалидной почтой#343
Open
r1m199 wants to merge 3 commits intoprofcomff:mainfrom
Open
фикс отсутствия ошибки при регистрации с невалидной почтой#343r1m199 wants to merge 3 commits intoprofcomff:mainfrom
r1m199 wants to merge 3 commits intoprofcomff:mainfrom
Conversation
BatuevIO
requested changes
Apr 19, 2026
| return async (...args: any[]) => { | ||
| const toastStore = useToastStore(); | ||
| try { | ||
| const response = await method(...args); |
Contributor
There was a problem hiding this comment.
Вот здесь и можно деструктурировать.
const {error, response} = await method(...args);| export function showErrorToast<F extends Func>( | ||
| method: F | ||
| ): Func<Promise<ReturnType<F>>, Parameters<F>> { | ||
| ): Func<Promise<{ error: any; response: ReturnType<F> | null }>, Parameters<F>> { |
Contributor
There was a problem hiding this comment.
Вот здесь с типами не нужно запариваться
Contributor
There was a problem hiding this comment.
Когда уберешь сложную конструкцию в конце, можно будет вернуть старые типы и все будет хорошо
| type: ToastType.Error, | ||
| }); | ||
| } | ||
| return { error: err, response: null }; |
Contributor
There was a problem hiding this comment.
Не стоит менять формат выходных данных, сложно обрабатывать потом будет. Давай здесь возвращать undefined
Contributor
There was a problem hiding this comment.
Ты, по сути, уже обработал ошибку, дальше ее прокидывать не нужно.
| return response; | ||
| } catch (err) { | ||
| const error = err as ApiError; | ||
| if ('error' in response) { |
Contributor
There was a problem hiding this comment.
Достаточно будет заменить на
if (error)
BatuevIO
requested changes
Apr 19, 2026
| const error = err as ApiError; | ||
| if ('error' in response) { | ||
| const errormessage = response.error?.detail?.[0].msg; | ||
| throw new Error(errormessage); |
Contributor
There was a problem hiding this comment.
Лучше здесь сделать
throw error;и обрабатывать все уже в catch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Действовал по шагам:
Деструктурировать ответ method как {error, response}
Если есть error, то пробросить error
Обозначить переменную error в блоке catch на выражение: err?.detail?.[0]?? err;
В toastStore.push в поле title добавить ?? error.msg ?? error
В итоге должен показываться тост с Value error,
Пришлось добавить err: any в catch, так как было неизвестно, есть ли detail у него
выброс ошибки возможно реализован коряво
Check-List
blackиisortдля Back-End илиPrettierдля Front-End?