-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: master
Are you sure you want to change the base?
Conversation
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
@maxonfjvipon, could you please review? |
@maxonfjvipon please, take a look |
if (options.verbose) { | ||
console.log(`Skipping ${pth} - already transpiled`); | ||
} | ||
return; |
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.
@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.`); |
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.
@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.`) |
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.
@2IMT I don't understand the purpose of the change
@2IMT It is not a good idea to name Git branches the way you named this one: " |