fix(dashboard): improve error toast message handling (#2692)

This commit is contained in:
Hassan Ben Jobrane
2024-05-08 12:35:21 +01:00
committed by GitHub
parent a58c5cfc96
commit 1bc615beca
2 changed files with 9 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
'@nhost/dashboard': patch
---
feat: improve error message handling in `ErrorToast` component

View File

@@ -29,10 +29,10 @@ const getInternalErrorMessage = (
if (error.name === 'ApolloError') {
// @ts-ignore
const internalError = error.graphQLErrors?.[0]?.extensions?.internal as {
error: { message: string };
};
return internalError?.error?.message || null;
const graphqlError = error.graphQLErrors?.[0];
const graphqlExtensionsError = graphqlError?.extensions?.internal
?.error as { message: string };
return graphqlError.message || graphqlExtensionsError?.message || null;
}
if (error instanceof Error) {