Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add exception handling for a `session()` and restore original engine if it fails
  • Loading branch information
logvinenko_da committed Sep 13, 2018
1 parent 639c408 commit 860fefd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ def session(self, **options):
engine = self.engine
self.engine = engine.__class__(
requests=utilities.merge_dicts(engine.requests, options.pop('requests', {})), **options)
yield self
self.engine = engine
try:
yield self
except exceptions.BaseRedmineError as e:
raise e
finally:
self.engine = engine

def upload(self, f):
"""
Expand Down

0 comments on commit 860fefd

Please sign in to comment.