Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Apr 22, 2024
1 parent 368b7e6 commit 4667230
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,13 @@ with escape(error_callback=lambda: print('Attention!')):
pass
```

If you pass a callback as a `before` parameter, it'll be called before the code block anyway:

```python
with escape(before=lambda: print('Attention!')):
pass
```

Notice, if an error occurs in this callback that will not be suppressed, the main code will not be executed - an exception will be raised before it starts executing.

If an error occurs in one of the callbacks, the exception will be suppressed if it would have been suppressed if it had happened in a wrapped code block or function. You can see the corresponding log entry about this if you [pass the logger object](#logging) for registration. If the error inside the callback has been suppressed, it will not affect the logic that was wrapped by `escape` in any way.

0 comments on commit 4667230

Please sign in to comment.