Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is a BusinessRuleException a checked or unchecked exception?

checked exception unchecked
0
10 Posted

Is a BusinessRuleException a checked or unchecked exception?

0

Index Short answer: checked. Long answer: In the book we have BusinessRuleException as a checked exception, but the alternative is not entirely verboten. The rationale is that the typical Java rule for when to use RuntimeException is that you should do it only if the exception is unlikely in a properly configured and written system. For example, a NullPointerException should not happen because a user did not enter something; the programmer has the option to check for null or ensure that values are always initialized. Since business rule exceptions can and generally do happen based upon user interaction they do not fall under this category. For example, a user might try to have a farmer milk a cow that was milked too recently. On the other hand, some people like to make everything a RuntimeException. They feel this makes their code “cleaner” in that they do not require try/catch blocks and “throws” clauses in their code. The problem here is that someone needs to catch the exception so t

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.