static Order checkout(Order order) `throws InvalidStatus, EmptyBasket`
```
]

---
# Exceptions interrupt the program immediately

<br>

.eighty-two-left[
```scala
def createUser(name: String, age: Int): User = {
  require(name.length > 0, "name should not be empty")
  require(age >= 18      , "user must be 18 years old or more")

  User(name, age)
}
```

```scala
createUser("", 12)
// java.lang.IllegalArgumentException: requirement failed: name should not be empty
```
]

---
# Solution 2: IO

<br>

.eighty-