~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/decorators.py

MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
217
217
 
218
218
 
219
219
def only_raises(*errors):
 
220
    """Make a decorator that will only allow the given error classes to be
 
221
    raised.  All other errors will be logged and then discarded.
 
222
 
 
223
    Typical use is something like::
 
224
 
 
225
        @only_raises(LockNotHeld, LockBroken)
 
226
        def unlock(self):
 
227
            # etc
 
228
    """
220
229
    def decorator(unbound):
221
230
        def wrapped(*args, **kwargs):
222
231
            try: