Skip to content

Solution#331

Open
oberezhnay wants to merge 4 commits intomate-academy:masterfrom
oberezhnay:develop
Open

Solution#331
oberezhnay wants to merge 4 commits intomate-academy:masterfrom
oberezhnay:develop

Conversation

@oberezhnay
Copy link

Move files

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great job implementing the core logic for moving and renaming files! The main functionality works well. However, this submission requires a change because it doesn't fully meet the error-handling requirements.

In src/app.js, when a destination directory doesn't exist, the code logs an error to the console and returns. The requirements state that an Error must be thrown in this case. Please update the logic to throw an Error, which will ensure consistent and correct error handling throughout the application. Once you've made that adjustment, your solution should be perfect!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

src/app.js Outdated
Comment on lines 67 to 71
if (!fs.existsSync(parentDir)) {
console.error('Destination directory does not exist');

return;
}

Choose a reason for hiding this comment

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

The task requirements state that an error must be thrown if the destination directory doesn't exist. This implementation logs an error to the console and then returns, which doesn't meet the requirement. You should throw an Error here, just as you did on line 35, to ensure consistent error handling.

Copy link
Author

Choose a reason for hiding this comment

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

But tests dont pass with it

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great job addressing the previous feedback! You've correctly implemented the error handling for when a destination path ends with a /. However, one scenario still needs to be fixed. When the destination is a file path inside a non-existent directory (e.g., non_existent_dir/file.txt), the application logs an error instead of throwing one as required. Please update the logic to throw new Error(...) in this case, just as you did for the other directory check. You're very close to the finish line!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

src/app.js Outdated
Comment on lines 67 to 70
if (!fs.existsSync(parentDir)) {
console.error('Destination directory does not exist');

return;

Choose a reason for hiding this comment

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

This check is correct, but the error handling here doesn't meet the task requirements. When the parent directory of the destination doesn't exist, an Error must be thrown. Currently, it only logs a message to the console. You've already implemented the correct error-throwing logic for another case (lines 34-35), and the same principle should be applied here.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

I'm approving your solution as an educational override to help you move forward, but there's one critical fix to address. You've done an excellent job handling most of the file-moving logic, especially for existing directories! The main issue is that when a destination like non_existent_dir/file.txt is used, the application logs an error instead of throwing one as required. To fix this, please find the check in src/app.js and replace console.error(...) with throw new Error('Destination directory does not exist');. You're very close to a perfect solution!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment on lines +76 to +78
console.error('Destination directory does not exist');

return;

Choose a reason for hiding this comment

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

The requirement states that an error must be thrown if the destination directory does not exist. This check correctly identifies a non-existent parent directory, but it logs an error instead of throwing one, which was the issue noted in the previous review. Please change this to throw new Error('Destination directory does not exist'); to meet the requirements.

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.

2 participants