6

Possible Duplicate:
In Java, when should I create a checked exception, and when should it be a runtime exception?

I heard a lot of things about Exception over RuntimeException but no clear arguments are given. I also see a lot of topics on Stack Overflow, but no one seems to be directly this question (if this is the case, thanks to close it as duplicate and show me the link !)

I would like to definitively knows when to use a RuntimeException and when to use a classic Exception.

For a business logic (ie the exception can be user fault (bad data) ), do you use exception or runtime ?

Have you got 2 or 3 advices you apply to choose to throw either an Exception or a Runtime Exception when you create your own Exception (in a business logic) ?

Community
  • 1
  • 1
Jerome Cance
  • 8,103
  • 12
  • 53
  • 106
  • 4
    http://stackoverflow.com/questions/499437/in-java-when-should-i-create-a-checked-exception-and-when-should-it-be-a-runti – Jonathon Faust Jan 06 '12 at 13:39
  • http://stackoverflow.com/questions/27578/when-to-choose-checked-and-unchecked-exceptions – mre Jan 06 '12 at 13:40
  • The answer is in your question. There is no definitive answer... But lots of duplicate questions – Lukas Eder Jan 06 '12 at 13:40
  • http://stackoverflow.com/questions/462501/exception-other-than-runtimeexception http://stackoverflow.com/questions/2750638/why-we-dont-have-to-add-try-catch-to-a-runtimeexception for explanations about the Exception types – jprofitt Jan 06 '12 at 13:41
  • I'd be wary of creating your own exceptions, especially if you're going to make it part of the API. – mre Jan 06 '12 at 13:42
  • Best practices for exception management in Java or C# http://stackoverflow.com/questions/409563/best-practices-for-exception-management-in-java-or-c-sharp – KV Prajapati Jan 06 '12 at 13:43
  • 1
    thanks a lot for all links (I dont know how I could missed them) ! I effectively see in other posts that there ins't a clear and unified answer... – Jerome Cance Jan 06 '12 at 13:53
  • @JeromeC., You just need to know what you're looking for. :D – mre Jan 06 '12 at 13:54

0 Answers0