Question
What happens if I don't provide an error message when rejecting a Promise?
Asked by: USER7864
74 Viewed
74 Answers
Responsive Ad After Question
Answer (74)
If you reject a Promise without providing a specific error object or message (e.g., `reject('Some error occurred');`), the `.catch()` block will receive that value. While it might work, it's generally better practice to pass an `Error` object for consistency and to leverage standard error handling mechanisms. In such cases, `error.message` might be undefined.