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

Improve error handling in transpile command #124

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

2IMT
Copy link

@2IMT 2IMT commented Dec 16, 2024

  • Catch all other errors in transform() function and report them to the user
  • Improve error messages for non-existent or invalid foreign files

@2IMT
Copy link
Author

2IMT commented Dec 17, 2024

@maxonfjvipon, could you please review?

@yegor256
Copy link
Member

@maxonfjvipon please, take a look

if (options.verbose) {
console.log(`Skipping ${pth} - already transpiled`);
}
return;
Copy link
Member

Choose a reason for hiding this comment

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

@2IMT we're trying to avoid multiple return statements, here's why: https://www.yegor256.com/2015/08/18/multiple-return-statements-in-oop.html

}
if (!foreign.endsWith('.json')) {
throw new Error(`Only .json foreign tojos file is supported, given ${foreign.substring(foreign.lastIndexOf(path.sep))}`)
throw new Error(`Invalid foreign tojo file format: ${foreign.substring(foreign.lastIndexOf(path.sep))}. Only .json files are supported.`);
Copy link
Member

Choose a reason for hiding this comment

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

@2IMT I don't understand the purpose of the change

@@ -122,10 +133,10 @@ const transpile = function(options) {
const foreign = path.resolve(options['target'], options['foreign'])
console.log(`Reading foreign tojos from: ${foreign}`)
if (!fs.existsSync(foreign)) {
throw new Error(`File ${foreign} is not found`)
throw new Error(`File not found: ${foreign}. Ensure the file exists and is accessible.`)
Copy link
Member

Choose a reason for hiding this comment

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

@2IMT I don't understand the purpose of the change

@0crat
Copy link

0crat commented Dec 26, 2024

@2IMT It is not a good idea to name Git branches the way you named this one: "master". You've earned -12 points. Next time, better give your branch the same name as the number of the ticket that you are solving. In this case, a perfect name, for example, would be "123".

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.

4 participants