Raise exception on invalid return.

Closes #10.