Fix for NullRef when handling errors in dynamic type

Fixes #20