Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 'something I read that it is considered "bad practice"' Can you clarify what is your source for this statement? Your question seems to be entirely based on this premise. Commented Aug 18, 2021 at 16:51
  • @VincentSavard stackoverflow.com/questions/613954/… . I have read multiple blogs, SO posts and articles about checked exceptions. I seriously don't know. I used to be always in favor of checked exceptions (as shown in my example). However, maybe my question refers to Java in specific and the way checked exceptions exist in Java. Nevertheless, I know that it is a controversial topic. But, for example, in my question, what alternatives do I have? If not checked exceptions? Commented Aug 18, 2021 at 17:01
  • 3
    I don't see anything wrong with the implementation you provided. I'd argue there's nothing wrong with checked exceptions even if they can be misused (just like, well, everything), but making the argument in the comments under your question does not seem like the appropriate place. :) Commented Aug 18, 2021 at 17:07
  • Does this answer your question? In Java, what are checked exceptions good for? Commented Aug 18, 2021 at 18:29
  • Do you need the stack trace? If not, use a return value instead. Commented Aug 19, 2021 at 5:28