diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-06-30 16:57:20 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-06-30 16:57:20 +0000 |
commit | 8c03fdf5f4b3b890d477bde1b4f7080b22b55447 (patch) | |
tree | cf0363173b40ba29d19f7d4a885d3e8c68973f10 /lib/sqlalchemy/util.py | |
parent | dc19e4eda67bfadb2d4456ecae3b49ae3a94fe95 (diff) | |
download | sqlalchemy-8c03fdf5f4b3b890d477bde1b4f7080b22b55447.tar.gz |
improved handling of exceptions upon __init__(): will preserve the stack
trace of the original __init__ exception; errors raised during session.expunge() will be
reported as warnings
Diffstat (limited to 'lib/sqlalchemy/util.py')
-rw-r--r-- | lib/sqlalchemy/util.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index ea5a468d2..0d66080ac 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -11,6 +11,8 @@ except ImportError: import dummy_threading as threading import md5 +import sys +import warnings import __builtin__ @@ -127,6 +129,13 @@ def duck_type_collection(col, default=None): else: return default +def warn_exception(func): + """executes the given function, catches all exceptions and converts to a warning.""" + try: + return func() + except: + warnings.warn(RuntimeWarning("%s('%s') ignored" % sys.exc_info()[0:2])) + class SimpleProperty(object): """A *default* property accessor.""" |