At database design I used Adapter pattern and came out with the following issue.
Should adapter class throw a general exception such as DatabaseException, or should it specify thrown exceptions ( ex: SecurityException, recordNotFoundException,..).
The problem with specified exception, it is hard to define all exceptions should be thrown by a method, and even if I could, it will be a long list.
Ex: Update method With assignment database class, this method will throw RecordNotfoundException and SecurityException. On another database implementation it could throw new exceptions such as InvaildDataType, ColumnNotFoud, TableNotFound�..
So should the Adapter class throws a general exception, or throw every expected exception.
I am some how with throwing a general exception, what comfort me more about this choice is how JDBC API works, where it throws a general SQL Exceptions. I know we are talking about totally deferent approach with JDBC since the main idea in JDBC is to execute SQL statements, and not calling database methods, but at the end the results are the same.
Any comment is appreciated.
Best Regards <br /> <br />Omar F. Kalaldah<br />---------------------<br />SCJP, SCJD, SCBCD
Yes, throw a general exception and chain the specific exception within it. You can do the same with RemoteExceptions by wrapping the Remote object in an adapter client side and extracting the RemoteException and rethrowing a general 'transport' exception.