-
Notifications
You must be signed in to change notification settings - Fork 2
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
NW6 | Error handling for get videos #23
Conversation
✅ Deploy Preview for watch-next-cyf ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
test (local changes) for .env
606f218
to
f1340dd
Compare
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.
Good work!
I rebased your branch with main branch and add .env.example back.
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.
Good work, one comment for a improvement you could make
} catch (error) { | ||
res | ||
.status(500) | ||
.json({ success: false, error: "Could not connect to the database" }); |
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.
It's good to see you doing some error handling and sending an error message! Question for you: Are exceptions always because the database can't be connected to?
They are likely to be, of course, but that doesn't mean they always are. Imagine, for instance, that you deleted the videos table by accident. This API would say it could not connect to the database which could lead to you spending hours troubleshooting the DB connection. It doesn't matter so much here but it's a good habit. If you have time try to implement it.
You can use examples in the the link to identify the type of error and return a custom error or you can take the message and class out of the error object and return these.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch#conditional_catch_blocks
No description provided.