Skip to content
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

Merged
merged 3 commits into from
May 14, 2024
Merged

Conversation

zelihapala
Copy link
Collaborator

No description provided.

Copy link

netlify bot commented May 13, 2024

Deploy Preview for watch-next-cyf ready!

Name Link
🔨 Latest commit af2c29c
🔍 Latest deploy log https://app.netlify.com/sites/watch-next-cyf/deploys/6643ea8d45fe91000897bd99
😎 Deploy Preview https://deploy-preview-23--watch-next-cyf.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

zelihapala and others added 2 commits May 14, 2024 23:38
@RbAvci RbAvci force-pushed the ZP/Error-Handling-for-Get-Videos branch from 606f218 to f1340dd Compare May 14, 2024 22:41
Copy link
Owner

@RbAvci RbAvci left a 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.

@RbAvci RbAvci merged commit fae9b84 into main May 14, 2024
6 checks passed
Copy link
Collaborator

@Ara225 Ara225 left a 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" });
Copy link
Collaborator

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

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.

3 participants