~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/decorators.py

  • Committer: Andrew Bennetts
  • Date: 2009-10-02 06:12:20 UTC
  • mto: This revision was merged to the branch mainline in revision 4732.
  • Revision ID: andrew.bennetts@canonical.com-20091002061220-tzyahxlz33ws2ppg
Update test_decorators, add docstring.

Show diffs side-by-side

added added

removed removed

Lines of Context:
207
207
 
208
208
 
209
209
def only_raises(*errors):
 
210
    """Make a decorator that will only allow the given error classes to be
 
211
    raised.  All other errors will be logged and then discarded.
 
212
 
 
213
    Typical use is something like::
 
214
 
 
215
        @only_raises(LockNotHeld, LockBroken)
 
216
        def unlock(self):
 
217
            # etc
 
218
    """
210
219
    def decorator(unbound):
211
220
        def wrapped(*args, **kwargs):
212
221
            try: