471,337 Members | 1,165 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Design question regarding exceptions.

I have a class called Users that provides a higher level of
abstraction to an underlying "users" table in a pgsql database. It
has methods like "addUser()" and "deleteUser()" which, obviously, wrap
the corresponding SQL statements. My question is would it better to
let any exceptions thrown by the underlying DB-API calls bubble up
from these methods, or should I catch them inside the methods, wrap
them inside my own custom exceptions, and throw those exceptions
instead?

Thanks.

-- Arcadio

Jul 17 '07 #1
1 966
asincero a écrit :
I have a class called Users that provides a higher level of
abstraction to an underlying "users" table in a pgsql database. It
has methods like "addUser()" and "deleteUser()" which, obviously, wrap
the corresponding SQL statements. My question is would it better to
let any exceptions thrown by the underlying DB-API calls bubble up
from these methods, or should I catch them inside the methods, wrap
them inside my own custom exceptions, and throw those exceptions
instead?
There's no absolute answer to this. But unless your "abstraction layer"
is supposed to be usable with non-DB-API backends (ie: text files, LDAP,
etc), I don't see any reason to abstract the exceptions.
Jul 18 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by fred | last post: by
3 posts views Thread by Steve - DND | last post: by
1 post views Thread by Dan | last post: by
6 posts views Thread by Mikus Sleiners | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.