Skip to content
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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Musyonchez
Copy link
Contributor

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.

Copy link

vercel bot commented Apr 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
saas-starter-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 13, 2024 6:35pm

pages/auth/sso/index.tsx Outdated Show resolved Hide resolved
@Musyonchez
Copy link
Contributor Author

@ukrocks007 Please check and advice.

locales/en/common.json Outdated Show resolved Hide resolved
@Musyonchez
Copy link
Contributor Author

@ukrocks007 Please check

@@ -83,9 +84,10 @@ const InviteViaLink = ({ team }: InviteViaLinkProps) => {
}
);

const result = (await response.json()) as ApiResponse;
Copy link
Contributor

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'));
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
toast.error(t(json?.error?.message || 'Something went wrong'));
throw new Error(t(json?.error?.message || 'Something went wrong'));

@@ -38,9 +38,10 @@ const APIKeys = ({ team }: APIKeysProps) => {
setSelectedApiKey(null);
setConfirmationDialogVisible(false);

const { error } = (await response.json()) as ApiResponse;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@ukrocks007 ukrocks007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
toast.error(t(json?.error?.message || 'Something went wrong'));
throw new Error(t(json?.error?.message || 'Something went wrong'));

@Musyonchez
Copy link
Contributor Author

@deepakprabhakara Somethings came up and i will not be able to finish this. Thanks for your understanding.

@deepakprabhakara
Copy link
Member

@Musyonchez No worries, we understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants