handle null data returned on error

Fixes issue #14