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

Throw TactCompilationError instead Error when possible #645

Closed
Tracked by #314
byakuren-hijiri opened this issue Aug 1, 2024 · 1 comment · Fixed by #669
Closed
Tracked by #314

Throw TactCompilationError instead Error when possible #645

byakuren-hijiri opened this issue Aug 1, 2024 · 1 comment · Fixed by #669
Assignees
Labels
api Tact's TypeScript API for third-party tools errors Error reporting mechanism good first issue Good for newcomers
Milestone

Comments

@byakuren-hijiri
Copy link
Contributor

Tact compiler throws exceptions when compilation errors occur. Typically, it uses throwCompilationError for this.

This enables the third-party tools to understand the reason of the exception by inspecting the error stacktrace, e.g.:

  static isCompilationError(stack: string | undefined): boolean {
    return stack !== undefined && stack.includes("at throwCompilationError");
  }

The problem is that in some cases we use throw new Error when compilation error occurs. For example, when an unresolved import appears:

throw new Error(`Could not resolve import "${i}" in ${path}`);

The idea is to examine all the cases when we throw and to replace them with throwCompilationError or throwInternalCompilerError if possible.

This will be helpful for the tooling and will provide a more unified internal API, fostering debugging of Tact.

@byakuren-hijiri byakuren-hijiri added good first issue Good for newcomers api Tact's TypeScript API for third-party tools labels Aug 1, 2024
@anton-trunov
Copy link
Member

This is definitely where we are going to. There is on detail, though. We should provide more info and not just throw TactCompilationError but differentiate between error kinds: parse errors, type errors, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Tact's TypeScript API for third-party tools errors Error reporting mechanism good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants