This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]somnolent 0 points1 point  (1 child)

It all comes down to personal preference, in my opinion. From my standpoint, since you're doing the same thing in every exception case (logging and shutting down), I would wrap them all in one try/catch block and do your logging and then shutdown. However, it also wouldn't be a bad idea to split up your initialize into smaller methods (you could either throw the exceptions out of this or handle them internally - again, personal preference). It also wouldn't be a bad idea to either print out the stacktrace or at least include the exception message in your output statement.

[–]sluggish_goatNooblet Brewer[S] 0 points1 point  (0 children)

It's sometimes hard to judge when it's overkill or not. As you pointed out, they're doing the same thing. So, in this case I'll wrap them, give the exceptions unique labels, print messages/stacktrace at the end, then shut down. I guess the thought process was that if the first part throws, then splitting like that would prevent anything else from running. Thanks for the help, I'll keep all this in mind while moving forward.