-
Notifications
You must be signed in to change notification settings - Fork 114
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay!
Oh, btw, let's add the Tact errors to |
message: string, | ||
source?: SrcInfo, | ||
): never { | ||
const loc = |
There was a problem hiding this comment.
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.
Closes #645
I have replaced
throw Error
withthrowInternalCompilerError
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 documented my contribution in Tact Docs: https://github.com/tact-lang/tact-docs/pull/PR-NUMBERI 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