Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

[#8] Add proper exception handling #9

Merged
merged 2 commits into from
Dec 27, 2023
Merged

[#8] Add proper exception handling #9

merged 2 commits into from
Dec 27, 2023

Conversation

Viicos
Copy link
Contributor

@Viicos Viicos commented Dec 22, 2023

Closes #9

@Viicos
Copy link
Contributor Author

Viicos commented Dec 22, 2023

@CharString, from what I remember when we talked about this:

  • it would be great to have two kinds of exceptions being raised: one when we have invalid json logic, the other one when the actual expected inferred type doesn't match. Any idea how we could distinguish both? I currently have only one exception for all possible errors.

In the form builder, I have the following validation snippet:

try {
  builderContext.validateLogic(val, [['', '']]);
} catch (error) {
  if (error instanceof InferenceError) {
    ctx.addIssue({
      code: z.ZodIssueCode.custom,
      message: error.message,
    });
  } else {
    ctx.addIssue({
      code: z.ZodIssueCode.custom,
      message: `Something went wrong when validating items expression: ${error.message}`,
    });
  }
}

I do have unexpected exceptions when using what looks like invalid json logic:

image

@Viicos
Copy link
Contributor Author

Viicos commented Dec 27, 2023

I will merge this, #9 (comment) can be sorted out later

@Viicos Viicos merged commit cf35b30 into main Dec 27, 2023
6 checks passed
@Viicos Viicos deleted the feature/8-exc branch December 27, 2023 15:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant