Throwing exception instead of returning `NULL`

Fixes #186