More specific exceptions (0.9.x)

Use more specific exceptions where possible.