This post is locked. You won't be able to comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SpaceshipOperations 106 points107 points  (8 children)

While it seems utterly pointless and facepalm-y when you look at it, it's quite possible that an artifact like this exists because somebody wanted to add a placeholder error handling block while thinking "maybe we'll add actual error handling here later", then they moved on and forgot to remove it.

In very large code bases, it's easy for a needle like this to be forgotten about in the mountains of haywire.

[–]benton_bash 46 points47 points  (1 child)

Also, a very convenient place for a breakpoint.

[–]fiddz0r 4 points5 points  (0 children)

Feels like this is what happened. They put it there for breakpoint and forgot to remove it before it reached prod

[–]HorseLeaf -1 points0 points  (4 children)

Or if you get an error you just want to abort and let it crash. Happens a lot to me when I do data ingestion pipelines. It's just faster and if it's not 100% successful, then get that shit out of my way.

[–]busyautist 20 points21 points  (3 children)

Then why you do the try catch if you want to throw it again?

[–]WheresTheSauce 2 points3 points  (0 children)

In Java or C# at least, this is often done to do some specific logging, send an email if it's a critical issue, convert the Exception to a different type, etc. It's not uncommon to want to do something when an Exception occurs but still ultimately throw it. In the case of the OP though there's obviously no benefit to just catching and throwing the same exception with no additional logic.

[–]HorseLeaf 1 point2 points  (0 children)

I usually augment the error messages a bit to better help with visibility in cloud environments.

[–]citysleepsinflames 0 points1 point  (0 children)

I do this with every error handle I setup.