Circle Saturday

They say what goes around comes around, and here I sit in a loop. Owen goes through phases, and as soon as I think it is done, here it is again. Before I understood any of this, and some days I still…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Why exception catching should be specific?

In development freshers are always tend to use the most generic exception handler for our code blocks. But did you ever think how much hastle it can bring if you fall in a critical bug in production?

Technically for now it will work in the place you catched the exception, But the problem arises when it catches the exception that shouldn’t be catched here.

Let’s see an example:

What should be the expected behaviour here? This function should raise an exception and caller of this should handle this exception.

Now let’s see the right Implementation

So in this way it will be very specific and easy to detect where the problem is actually happening.

Add a comment

Related posts:

Building a Startup completely in the Open

The importance of user feedback and community support before launching a new product is huge. Users are full of surprises, it’s long been established that developers make many assumptions about how a…

TEDxRUPP 2020 Recap

No one could have guessed that 2020 would be this unpredictable. However, through thick and thin, TEDx RUPP has never abandoned our mission, spreading ideas. This year, TEDxRUPP is proud to…

When air travel is restricted how do humanitarian workers get to where they are needed most?

In early April the Government of Kenya effected movement restrictions from and into the Nairobi Metropolitan Zone in a bid to control the spread of COVID-19. However essential workers such as…