Skip to content

promise#1533

Open
masteryada378 wants to merge 2 commits into
mate-academy:masterfrom
masteryada378:develop
Open

promise#1533
masteryada378 wants to merge 2 commits into
mate-academy:masterfrom
masteryada378:develop

Conversation

@masteryada378
Copy link
Copy Markdown

Copy link
Copy Markdown

@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

Your implementation has functional issues that need fixing. The main problem is in your .catch() handlers - you're passing the entire Error object to createMessage() instead of extracting the message text. This causes [object Error] to display instead of Promise was rejected!. Fix by using err.message in your catch callbacks. Additionally, there's a chaining issue with promise2 - when you call .then() followed by .catch(), both handlers can execute if the promise rejects, which means the success handler will incorrectly display text before the catch handler. Make sure to return the promise from .catch() or use proper promise chaining so handlers don't overlap.


✨ 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

Comment thread src/scripts/main.js
Comment on lines +31 to +32
promise2
.then((msg) => createMessage(msg))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The .then() handlers will display whatever value is passed to resolve() or reject(). For promise2, since it never resolves, the .then() won't run - the .catch() will. However, the .catch() receives an Error object, not a string, causing [object Error] to be displayed instead of the actual message.

Comment thread src/scripts/main.js
.catch((err) => createMessage(err, true));

promise2
.then((msg) => createMessage(msg))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This .catch() receives an Error object. When passed to createMessage(), it becomes [object Error] instead of Promise was rejected!. Should pass err.message to get the actual error text.

Comment thread src/scripts/main.js
});

promise1
.then((msg) => createMessage(msg))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similar issue - the .catch() receives an Error object. Should pass err.message to get the actual error text.

Copy link
Copy Markdown

@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

Your implementation meets all requirements successfully. Both promise1 and promise2 are correctly created with new Promise(), the first resolves on .logo click using { once: true }, and the second rejects after 3 seconds using setTimeout. Each promise has proper .then() and .catch() handlers that append the exact message divs as specified, with the error handler correctly using the error-message class and passing err.message to your createMessage function. The code is clean, functional, and all checklist items have been verified. Great work!


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

Footnotes

  1. Rate AI review example

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