• Post Reply Bookmark Topic Watch Topic
  • New Topic

a question about throw exception

 
lijun wang
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do I need throw the exception which I catched in DAO to high level, like facade? if the answer is yes, why?
Thanks.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36032
432
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lijun,
Yes. You can throw the same exception or wrap it in a custom exception.

If the database layer doesn't throw an exception, how does your code know something is wrong?
 
lijun wang
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so thorw exception to high level is to keep the trace when I debug the code, is that right?
thanks.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36032
432
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lijun ,
Throwing the same exception keeps the strack trace. Throwing a different exception stars a new stack trace.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!