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

Enhance error handling to support third-party tools #509

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

rahulyadav-57
Copy link
Member

Closes #262

  • 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

- Replaced consoleLogger with the new Logger
- Removed jest mock where consoleLogger was used
- Improved support for third-party tools
});
if (!c.ok) {
console.error(c.log);
logger.error(c.log);
process.exit(1);
Copy link
Member

Choose a reason for hiding this comment

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

My guess would be that all things like process.exit should also go

@anton-trunov
Copy link
Member

Any progress here?

@rahulyadav-57 rahulyadav-57 marked this pull request as ready for review July 3, 2024 10:42
if (message instanceof Error) {
message = message.stack || message.message;
} else {
message = "" + message.toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we simply use message.toString() here?

const message = "Bindings compiler crashed";
logger.error(message);
logger.error(e as Error);
errorMessages.push(new Error(message));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also include e to the errorMessages structure? It might be useful to third-parties, I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that would be a better.

const message = "Report generation crashed";
logger.error(message);
logger.error(e as Error);
errorMessages.push(new Error(message));
Copy link
Contributor

Choose a reason for hiding this comment

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

See previous

}) {
const configWithRootPath = await loadConfig(args.fileName, args.configPath);
if (!configWithRootPath) {
return false;
return { ok: false, error: [new Error("Unable to load config")] };
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Maybe we should add args.configPath to the error message in order to give more context to the user.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can change it to something `Unable to load config from path: ${args.configPath}`


export async function build(args: {
config: ConfigProject;
project: VirtualFileSystem;
stdlib: string | VirtualFileSystem;
logger?: TactLogger | null | undefined;
}) {
logger?: Logger | null | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

This type definition looks a bit strange, right? What is the different between null and undefined values? What value will be used if we write if (!logger) { in the function body?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can remove both null and undefined since it will be undefined by default.

@@ -111,7 +112,7 @@ export async function build(args: {
let codeEntrypoint: string;

// Compiling contract to func
logger.log(" > " + contract + ": tact compiler");
logger.info(" > " + contract + ": tact compiler");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Maybe we should use string interpolation in the similar cases instead. AFAIK we prefer that style when refactoring the project, but it's up to you.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I'll do it. I haven't done the refactoring yet, but I'll take care of it.

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.

Enhance error handling in Tact compiler to support third-party tools
3 participants