On Wednesday 31 May 2006 23:28, Oleg Broytmann wrote:
>    The problem that I see with the plan is that if SQLObject starts
> catching all exceptions from DB API drivers and translate them to a
> single exception that would mask low-level exceptions and it would be
> hard to monitor what driver raises what exception in what situation;

something like this can be used to know what low level exception was from 
what module (say within the MySQL backend):

try:
  code
except MySQLdb.IntegrityError, why:
  raise some specific integrity sqlobject exception
...
# other specific errors handled here
...
except MySQLdb.Error, why:
  # handle all other errors here in a generic way
  info = sys.exc_info()
  try:
     mod = info[0].__module__
     exc = info[0].__name__
  finally:
     del info
  raise DatabaseError, "%s.%s: %s" % (mod, exc, str(why))

This will show (at least informational) the original exception module and 
name in the string detail of the generic exception.

> logging would be of some help, but we need to add a lot of logging
> information; unfortunately Python does not have "exception chaining".
> The subproblem is that if the single high-level exception solves 60% of
> problems with exceptions nobody would like to work in the area further.

That is true, but in the end do you prefer a solution that covers 60% of 
the usage cases out there right now or do you prefer to wait until 
someone will implement the perfect 100% complete solution somewhere in 
the unknown future? Because 1st option IMO will be better than what we 
have right now and someone who needs more can extend it easily.

>    Other than that it is a good plan!
>
> Oleg.

-- 
Dan


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to