I think this line is short-enough for a oneliner:

```
raise XYZ if primary_key.nil?
``