-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1285 API Errors not localized #1321
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@ukrocks007 Please check and advice. |
@ukrocks007 Please check |
@@ -83,9 +84,10 @@ const InviteViaLink = ({ team }: InviteViaLinkProps) => { | |||
} | |||
); | |||
|
|||
const result = (await response.json()) as ApiResponse; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can keep it inside the if condition in all the places, it is saving unnecessary read of the body.
const json = await response.json(); | ||
throw new Error(json.error.message); | ||
const json = (await response.json()) as ApiResponse; | ||
toast.error(t(json?.error?.message || 'Something went wrong')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If error is not thrown here the code bubbles down, need to return here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deepakprabhakara ok am lost is the way shown above the correct way or relace the green line 40 toast.error with throw new Error to be caught by the catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toast.error(t(json?.error?.message || 'Something went wrong')); | |
throw new Error(t(json?.error?.message || 'Something went wrong')); |
components/apiKey/APIKeys.tsx
Outdated
@@ -38,9 +38,10 @@ const APIKeys = ({ team }: APIKeysProps) => { | |||
setSelectedApiKey(null); | |||
setConfirmationDialogVisible(false); | |||
|
|||
const { error } = (await response.json()) as ApiResponse; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be inside the if block below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in the "refactor: add error destructuring into the if statement" commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saas-starter-kit/check-locale.js
Line 9 in ea93d79
const exceptionList = [ |
Add Something went wrong
to exceptionList in check-locale.js
file
const json = await response.json(); | ||
throw new Error(json.error.message); | ||
const json = (await response.json()) as ApiResponse; | ||
toast.error(t(json?.error?.message || 'Something went wrong')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toast.error(t(json?.error?.message || 'Something went wrong')); | |
throw new Error(t(json?.error?.message || 'Something went wrong')); |
@deepakprabhakara Somethings came up and i will not be able to finish this. Thanks for your understanding. |
@Musyonchez No worries, we understand. |
I added localized translations for "Something went wrong" as it is static. For the others it may be tricky as the response is diffrent. Like some have the response status inlaided within the string so one has to extract it translate and then put it back in.
Also i did two more for avataupload.