DEV Community

Cover image for Advanced Error Handling in Node.js

Advanced Error Handling in Node.js

Amruta on June 04, 2024

Error handling is an important aspect of software development that ensures your application behaves predictably and provides meaningful feedback wh...
Collapse
 
litlyx profile image
Antonio | CEO at Litlyx.com

Really good article! We have created this open-source project, where you can track anything in your web-app or website. You can customize your events too, and can be used even in production with 'Error Events' so you can always check where the exception are even in production!

The project is open-source on Github.

Antonio, CEO & Founder at Litlyx.com

Collapse
 
rkristelijn profile image
Remi Kristelijn

Great article! I want to point out that extensive logging, especially when explicitly writing to a file can result a performance issue. Therefore you could just log to the console and let e.g. kubernetes handle the logging. Also central logging is important, e.g. use of open search and e.g. npmjs.com/package/console-log-json

Collapse
 
devpaul3000 profile image
Dev Paul

Great article. Creating custom error classes is a really powerful approach that make error handling a easy and sometimes fun

Collapse
 
the_riz profile image
Rich Winter • Edited

Good stuff.
Don't forget that Promises both resolve and reject

Collapse
 
amritak27 profile image
Amruta

You're right, Promises can resolve and reject, and it's important to handle both cases

Collapse
 
syedmuhammadaliraza profile image
Syed Muhammad Ali Raza

nice

Collapse
 
mehedihasan2810 profile image
Mehedi Hasan

Good read

Collapse
 
learn_with_santosh profile image
Santosh Shelar

Great advice! These best practices ensure your applications can gracefully handle errors and provide a better user experience.

Collapse
 
mrrishimeena profile image
Rishi Kumar

Check out opensource library GitHub errsole.js , Its the first in world opensource 'logging library' which has built-in dashboard. Its much better than winston, pino and even paid cloudwatch.

Collapse
 
mrrishimeena profile image
Rishi Kumar

True, Error handling is the first part towards debugging the issues in Node.js . Its the first step towards knowing the root cause of the error. There are many more steps afterwards to find and verify the fix of the issues. But its takes hours. Thats why we build the errsole which can helps the developers to fix the errors in minutes.

Collapse
 
jackson_brown_c38e04bcf2a profile image
Info Comment hidden by post author - thread only accessible via permalink
Jackson Brown

I've been in the real estate business for over 20 years and I was always on the lookout for new lucrative investments. Bitcoin caught my eye early on, and I decided to invest $10,000 in purchasing Bitcoin. Over time, my investment shot to $600,000. This significant profit margin allowed me to expand my real estate business and purchase additional properties. However, my joy turned to panic when I received an email that seemed to be from my trading platform. It asked me to verify my account details. Without hesitation, I provided the information. Soon after, I discovered that my Bitcoin wallet had been drained. Devastated, I sought help and found a recommendation for Dumbledore web expert Recovery on a real estate forum. I contacted them immediately, hoping they could assist me. Their team was highly professional and quick in their response. They meticulously traced the fraudulent activity and managed to recover most of my funds. Dumbledore web expert also educated me on crucial security measures. They emphasized the importance of using two-factor authentication, creating strong, unique passwords, and recognizing phishing attempts. This experience was a tough lesson, but their guidance helped me secure my Bitcoin more effectively for the future. I will advise everyone to contact Dumbledore web expert if your bitcoin was stolen or you being scammed through their contact info below :

Email: dumbledorewebexpert(@)usa.com
WhatsApp: +1-(231)-425-0878

Collapse
 
jackson_brown_c38e04bcf2a profile image
Jackson Brown

I've been in the real estate business for over 20 years and I was always on the lookout for new lucrative investments. Bitcoin caught my eye early on, and I decided to invest $10,000 in purchasing Bitcoin. Over time, my investment shot to $600,000. This significant profit margin allowed me to expand my real estate business and purchase additional properties. However, my joy turned to panic when I received an email that seemed to be from my trading platform. It asked me to verify my account details. Without hesitation, I provided the information. Soon after, I discovered that my Bitcoin wallet had been drained. Devastated, I sought help and found a recommendation for Dumbledore web expert Recovery on a real estate forum. I contacted them immediately, hoping they could assist me. Their team was highly professional and quick in their response. They meticulously traced the fraudulent activity and managed to recover most of my funds. Dumbledore web expert also educated me on crucial security measures. They emphasized the importance of using two-factor authentication, creating strong, unique passwords, and recognizing phishing attempts. This experience was a tough lesson, but their guidance helped me secure my Bitcoin more effectively for the future. I will advise everyone to contact Dumbledore web expert if your bitcoin was stolen or you being scammed through their contact info below :

Email: dumbledorewebexpert(@)usa.com
WhatsApp: +1-(231)-425-0878

Collapse
 
jean_claire_213b658ba9257 profile image
Info Comment hidden by post author - thread only accessible via permalink
Jean Claire

I lost access to my Crypto when the wallet service I was using went offline permanently. So I have been struggling for months to try and figure out how I will access my wallet again. After much struggle, a co worker of mine referred me to SPYHOST CYBER SECURITY COMPANY. I was pleased with their services because their communication was quick, transparent, and professional. I provided the necessary requirements to them and that was the beginning of my journey of my successful recovery. In short, they really renewed my hope and brought me happiness once more which i never thought could be possible. Spyhost was very responsive to emails and after some hours (48) they recovered my wallet. They acted professionally and in accordance with our agreement and without doubt i was suprised and convinced that we still have some trustable recovery company out there of which Spyhost is one I would highly recommend using Spyhost Cyber Security Company. For anyone who are in same situation as me or in need of other sort of help related to crypto funds recovery below is their email contact to send a request or complaint ( spyhost@cyberdude. com) while their whatsapp contact is [ +1(571) 478-7636 ]

Collapse
 
malik_gordons_5f1fa9782c3 profile image
Info Comment hidden by post author - thread only accessible via permalink
Malik Gordons

PLEASE READ!!
This is my life story about a recent encounter with VIRTUALHACKNET RECOVERY FIRM. After being scammed by a group of individuals on the Telegram app, I sought help from the best recovery hacking agency out there. The scam company I was involved with made me believe that my funds were invested in stocks like AMAZON and APPLE. They had me download the MetaTrader app and Trust Wallet, which I used to fund the other trading app. After making several wire transfers amounting to over $140,000, I realized I was involved in a scam investment chain.
After this revelation, I reported the case to the NYPD with proof of transfers made to the company. However, after a month of investigation, the only response I received was that crypto assets could not be traced, and they were sorry to inform me of this. I was incredibly disappointed that the authorities couldn’t handle such a crime. I almost gave up, but my instincts told me there must be a way to recover the funds, and I just needed to research properly.
I went online searching for a reputable organization to help recover my loss, and I stumbled upon VIRTUALHACKNET RECOVERY FIRM’s email contact: VIRTUALHACKNET @ G MAIL . COM. I quickly sent them all the details about the failed investment, and they immediately started tracking my funds. The entire process took just about 72 hours, and my funds were recovered back to my bank account without any stress. This surprised me because the NYPD cyber department had declared that the funds could no longer be recovered. I’m grateful I didn’t give up, even after receiving the news from them.To all the victims out there who believe that crypto assets cannot be recovered, you’re wrong. I’m a witness to VIRTUALHACKNET RECOVERY FIRM’s capability to handle investment cases and ensure you get back what you’ve lost in full. You can also reach them for their services on Telegram at VIRTUALHACKNET.

Collapse
 
darwin_calgary_58fc49df82 profile image
Info Comment hidden by post author - thread only accessible via permalink
Darwin Calgary

My goal was always to provide the best for myself and my family. With this in mind, I decided to invest a significant amount of money in cryptocurrency. Unfortunately, this decision nearly led to financial ruin when I was scammed by the company I invested with. However, my situation turned around with the assistance of K N I G H T H O O D B O T H A C K C O R P. This well-known recovery company specialises in handling cyber fraud cases like mine, offering their services without unnecessary stress.When I reached out to K NI G H T H O O D B O T H A C K C O R P, I was eager to work closely with them to recover the funds I had lost. To my relief, the results exceeded my expectations. The professionals at K N I G H T H O O D B O T H A C K C O R P guided me through every step of the recovery process until we achieved a successful outcome. Initially, I believed my funds were lost forever, especially with the warning messages I received during crypto transactions stating, "Check wallet address again before sending, once assets are sent out they cannot be traced or recovered." It turns out, this was a result of my lack of information and not having the right contacts to handle such cases. K N I G H T H O O D B O T H A C K C O R P provided the security and protection I needed against the scammers.
At first, I was skeptical about working with K N I G H T H O O D B O T H A C K C O R P, mainly due to my previous negative experience with the investment company I found online. However, after a detailed explanation from the team during a phone call, my doubts were put to rest. KNIGHTHOODBOT HACK CORP has repeatedly proven themselves as the solution to scam-related cases.
If you ever find yourself entangled in an online scam, I strongly recommend reaching out to K N I G H T H O O D B O T H A C K C O R P. You can contact them via email at KNIG HTHOODBOT AT Gmail dot COM or through Telegram at KNIGHTHOODBOT9. They can efficiently trace and recover your lost funds, just as they did for me.

Collapse
 
graham_smith_8a090f5b5336 profile image
Info Comment hidden by post author - thread only accessible via permalink
Graham Smith

RELIEF FOR CRYPTO SCAM VICTIMS; FUNDS RETRIEVED BY GRAYHATHACKS CONTRACTOR

I am thrilled to share my experience with Grayhathacks Contractor, as I never thought I would be one of those people writing a positive review for an online service. I was fully prepared to rant about being scammed further, but luckily I stumbled upon an honest team of hackers who are out to help.

After falling victim to a well-executed investment scam that cost me nearly a quarter of a million dollars, I decided to take a chance on Grayhathacks Contractor. And boy, did they deliver!

Specializing in crypto recovery, Grayhathacks Contractor is a team of expert professionals dedicated to helping individuals and businesses reclaim their lost funds from investment scams. With their impressive track record and top-notch customer service, I was hopeful that I was in good hands.

I was not disappointed. Thanks to their efforts, we were able to track down the scammers and recover the full amount I had lost and all within a short period of a week. I couldn't believe it either once I saw the funds back in my wallet, I thought it was a trick. Imagine how happy I felt after I verified that indeed I got my funds back.

I cannot thank Grayhathacks enough for their exceptional service. They truly are the best in the business when it comes to crypto tracking and recovery. If you ever find yourself in a similar situation, do not hesitate to reach out to them using the contact information provided below.

WhatsApp: +1 (843) 368-3015
Email:
grayhathacks@contractor.net
Image description

Collapse
 
bella_ani_425c1043fda7d86 profile image
Bella Ani

HOW I WAS ABLE TO RECOVER MY STOLEN CRYPTO BACK //  ALL THANKS TO HACKANGELS RECOVERY HACKER
Do you need help in reclaiming lost Crypto Wallets from Scammers? There is only one way to go about it, Contact HACKANGELS RECOVERY HACKER to do all in its power to help you recover it all. A specialized Expert with cyber specialties to recover scammed funds. They work with professionalism and discretion. I was in total dismay when I lost my entire savings investing in cryptocurrency. I came to learn about  HACKANGELS RECOVERY HACKER through my old friend. With a little faith in me, I contacted them immediately, and discussed my situation, and sent all the information I had. In less than 48 hours I was able to recover funds back. They are capable of recovering any crypto coins. I’m truly grateful for their service and I recommend them to everyone who needs to recover their funds. For further information. You can contact them through their hotline  
WhatsApp +1(2320520)200- Email at support@thehackangels.com. Website at thehackangels.com

Collapse
 
jean_douglas_10fd61be4947 profile image
Jean Douglas

I contacted H A C K M A V E N S C R E D I T S P E C I A L I S T a few days ago through text and surprisingly they are carrying out an actual credit fix, my score was raised from 514 to 765 excellent score within 5days and all repossession, derogatory, and inquiries were deleted from my report! I took advantage of this and you too can by reaching out to them via EMAIL: H A C K M A V E N S 5 (AT) G M A I L (DOT) C O M or Call/Text/Whats-App: [+ 1 (2 0 9) 4 1 7 – 1 9 5 7] and I’m sure you will be happy you did.

Collapse
 
michael_marie_4d05a1b8e6b profile image
Info Comment hidden by post author - thread only accessible via permalink
Michael Marie

Cyberspace Hack Pro came to my rescue when I was at my lowest, having fallen victim to a deceitful Forex Investment Company. The loss of my hard-earned funds left me feeling defeated and unsure of where to turn. However, upon discovering Cyberspace Hack Pro, I found renewed hope and determination.They immediately apparent. Their team of experts and hackers demonstrated unparalleled skill and dedication in their mission to help me. They left no stone unturned, tirelessly pursuing justice on my behalf. Their commitment to aiding individuals like myself in navigating the treacherous world of online fraud was truly commendable.But what truly sets Cyberspace Hack Pro apart is their unwavering determination to deliver results. Through their relentless efforts, they managed to track and recover the entirety of my lost funds, totaling an impressive 4.26476 BTC. This achievement not only lifted a huge weight off my shoulders but also restored my faith in the possibility of justice prevailing, even in the digital realm.the recovery process, Cyberspace Hack Pro provided unwavering support and guidance. They kept me informed every step of the way, offering reassurance and direction during what was undoubtedly a challenging time. Their professionalism and empathy served as a beacon of hope, reminding me that I was not alone in my quest for restitution.Looking back on my experience, I am filled with gratitude for having found Cyberspace Hack Pro. Their expertise and dedication turned what initially seemed like an insurmountable obstacle into a triumph of justice. Recovering my lost funds through their assistance stands as one of the best decisions I made this year, a testament to their efficacy and reliability.For anyone facing a similar situation, I wholeheartedly recommend reaching out to Cyberspace Hack Pro. Their proven track record and unwavering commitment to client satisfaction make them the go-to choice for recovering lost funds from online scams. With Cyberspace Hack Pro by your side, you can rest assured that you are in capable hands, guided by professionals who prioritize your interests above all else. Cyberspace Hack Pro exceeded all my expectations, delivering results that surpassed my wildest dreams. Their professionalism, expertise, and unwavering dedication to client satisfaction set them apart as industry leaders in the realm of fund recovery. Trusting Cyberspace Hack Pro was undoubtedly one of the best decisions I made this year, and I am forever grateful for their assistance in reclaiming my digital assets into my account.

WhatsApp:  +1 (440) 7423096

E-MAIL; Cyberspacehackpro(@)rescueteam. com

cyberspacehackpro0.wixsite.com/cyb...

Uploading image

Collapse
 
william_ford_9c904278b1cc profile image
William Ford

CONTACT SUPERIOR . HACK @ GMAIL . COM OR WHATSAPP +14106350697 for all your hacking or pi job they are very sharp discreet and competent at their job they helped me to hack into my spouse phone and found out he was cheating they helped recover my stolen cryptocurrency and cleared my bad credit report contact them and thank me later

Collapse
 
chiemenagodswill profile image
Chiemena Godswill

wonderful article

Collapse
 
fortune_coder profile image
Shedrack Davis

I love it. Thanks for sharing.

Some comments have been hidden by the post's author - find out more