hitaco
发贴: 432
积分: 31
|
于 2004-06-17 10:13
I am afraid most applications(at least in my company), will not do anything other than a friendly UI when SQLExceptino occur, so, there is no need to wrap/rethrow the SQLException. Something like exception handler in Struts or declarative exception configuration in web.xml is enough, that means, we can use generic means to catch/handle exception rather than duplicating the "try/catch/forward to error page" logic everywhere in the source code.
Of course, what kind of exception to use should be taken into consideration in serious project.
jigsaw wrote: to hitaco abt exceptions: no matter DAO/EJB throws RuntimeException or checked exception, client class is expected to catche them, since exceptions are return from method. However SQLException contains not enought infos abt wot's happening, so we have to wrap it w/ app-spec exception to tell client class wot's going on there. if a wrapper of low level exception is not able to tell in a non-ambiguous way, it should be defined as a runtime exception which means client dont have to catch it, just let CMT to rollback and display a common error message to end user.
|