mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-18 23:45:26 +02:00
feat: Show generic error when no custom error specified
This commit is contained in:
parent
9c85cc13ac
commit
5e979f70c7
@ -28,17 +28,18 @@ export default function useErrorSuccessSnacks(): UseErrorSuccessSnacksResult {
|
||||
})
|
||||
}
|
||||
const showError = (error: Error) => {
|
||||
const parsedError = parseFastAPIError(error as AxiosError)
|
||||
let message
|
||||
|
||||
if ("detail" in parsedError) {
|
||||
$errorSnackbarKey.current = enqueueSnackbar(
|
||||
parsedError.detail || t("general.defaultError"),
|
||||
{
|
||||
variant: "error",
|
||||
autoHideDuration: ERROR_SNACKBAR_SHOW_DURATION,
|
||||
},
|
||||
)
|
||||
}
|
||||
try {
|
||||
const parsedError = parseFastAPIError(error as AxiosError)
|
||||
|
||||
message = parsedError.detail
|
||||
} catch (e) {}
|
||||
|
||||
$errorSnackbarKey.current = enqueueSnackbar(message || t("general.defaultError"), {
|
||||
variant: "error",
|
||||
autoHideDuration: ERROR_SNACKBAR_SHOW_DURATION,
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user