Raise exception on invalid return.

Closes #11.