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 internal/compiler errors instead Error when possible #669

Merged
merged 8 commits into from
Aug 9, 2024

Conversation

jubnzv
Copy link
Member

@jubnzv jubnzv commented Aug 8, 2024

Closes #645

I have replaced throw Error with throwInternalCompilerError in most cases, as that's essentially how the compiler should behave. If the user encounters an "impossible" case, they should definitely be encouraged to report it.

Otherwise, if we encounter this kind of error while using the compiler API in a tool, we should understand that we are using it incorrectly.

Note that I didn't modify the old backend, as it will be rewritten anyway.

  • I have updated CHANGELOG.md
  • I have documented my contribution in Tact Docs: https://github.com/tact-lang/tact-docs/pull/PR-NUMBER
  • I have added tests to demonstrate the contribution is correctly implemented: this usually includes both positive and negative tests, showing the happy path(s) and featuring intentionally broken cases
  • I have run all the tests locally and no test failure was reported
  • I have run the linter, formatter and spellchecker
  • I did not do unrelated and/or undiscussed refactorings

@jubnzv jubnzv marked this pull request as ready for review August 8, 2024 13:02
@anton-trunov anton-trunov added this to the v1.4.2 milestone Aug 8, 2024
@anton-trunov anton-trunov self-assigned this Aug 8, 2024
anton-trunov
anton-trunov previously approved these changes Aug 8, 2024
Copy link
Member

@anton-trunov anton-trunov left a comment

Choose a reason for hiding this comment

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

Yay!

@anton-trunov
Copy link
Member

anton-trunov commented Aug 8, 2024

Oh, btw, let's add the Tact errors to index.ts as well in this PR

@anton-trunov anton-trunov mentioned this pull request Aug 8, 2024
6 tasks
@anton-trunov anton-trunov merged commit ce4644e into tact-lang:main Aug 9, 2024
3 checks passed
message: string,
source?: SrcInfo,
): never {
const loc =
Copy link
Member

@Gusarich Gusarich Aug 9, 2024

Choose a reason for hiding this comment

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

It's now less informative in some cases. For example, when trying to compile non-existing project source:

💼 Compiling project getters ...
Tact compilation failed
Error
    at throwCompilationError (/Users/daniil/Coding/tact/src/errors.ts:91:11)
    at resolveImports (/Users/daniil/Coding/tact/src/imports/resolveImports.ts:28:30)
    at precompile (/Users/daniil/Coding/tact/src/pipeline/precompile.ts:18:36)
    at build (/Users/daniil/Coding/tact/src/pipeline/build.ts:73:25)
    at run (/Users/daniil/Coding/tact/src/node.ts:130:34)
    at async /Users/daniil/Coding/tact/scripts/prepare.ts:20:31
Error: Tact projects compilation failed
    at /Users/daniil/Coding/tact/scripts/prepare.ts:24:19
error Command failed with exit code 1.

while before it would throw Could not find entrypoint XXX.

I think the problem is here, because it ignores message in case if no source location was provided.

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.

Throw TactCompilationError instead Error when possible
3 participants