Skip to content

Commit

Permalink
upd recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
orsinium committed Apr 20, 2020
1 parent 05a1cd1 commit 99e0b96
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/recipes.md
Expand Up @@ -50,7 +50,14 @@ If a contract needs only function arguments, use `pre`. If a contract checks onl

## Prefer `reason` over `raises`

Always try your best to tell why exception can be raised.
Always try your best to tell why exception can be raised. However, keep in mind that all exceptions from `reason` still have to be explicitly specified in `raises` since contracts are isolated and have no way to exchange information between each other:

```python
@deal.reason(ZeroDivisionError, lambda a, b: b == 0)
@deal.raises(ZeroDivisionError)
def divide(a, b):
return a / b
```

## Keep module initialization pure

Expand Down

0 comments on commit 99e0b96

Please sign in to comment.