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

Fix type gen bug #449

Merged
merged 3 commits into from
Dec 19, 2023
Merged

Fix type gen bug #449

merged 3 commits into from
Dec 19, 2023

Conversation

roshaans
Copy link
Contributor

We have an issue where if the formatting of SQL is not current or we encounter a case in which we do not support the type generation library for the context method, we fail very abruptly.

This PR handles these errors better.

  • If sql/code encounters syntax error and formatting fails, we simply return the unformatted code to the editor so the user can fix it.
  • If code + sql both have syntax errors, the user will now see two different alerts. One for each one of them.
  • We throw the error, but we also log everything to console for debugging purposes.
  • We catch and throw type generation errors in a new variable.

@roshaans roshaans requested a review from a team as a code owner December 14, 2023 19:04
@roshaans roshaans requested a review from darunrs December 14, 2023 20:17
setError(() => undefined);
} catch (error) {
handleCodeGenError(error);
setTypesGenerationError(() => undefined);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
setTypesGenerationError(() => undefined);
setTypesGenerationError(undefined);

Using a function is only necessary when you intend to use the existing state, i.e. (currentState) => currentState + 1

async function handleFormating() {
await reformat(indexingCode, schema);
await reformatAll(indexingCode, schema);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
await reformatAll(indexingCode, schema);
reformatAll(indexingCode, schema);

This function is not async

Copy link
Collaborator

@darunrs darunrs left a comment

Choose a reason for hiding this comment

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

FYI, I tried to run the frontend locally again, since it's been a while. But, it wasn't loading for some reason. I did:

  1. yarn serve:widgets:local
  2. Set flag to http://127.0.0.1:3030
  3. Ran yarn dev in a separate terminal
  4. Visited localhost:3000.

I was stuck at the loading screen.

handleCodeGenError(error);
setTypesGenerationError(() => undefined);
} catch (typesError) {
console.log("typesGenerationError generating types for saved schema.\n", typesError);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be a console.error? Same for the others.

@roshaans roshaans merged commit 61f92a8 into main Dec 19, 2023
2 checks passed
@roshaans roshaans deleted the fix-type-gen-bug branch December 19, 2023 23:53
@roshaans roshaans mentioned this pull request Dec 19, 2023
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.

Error Handling is inconsistent for code + schema + type generation flows
3 participants