make error reporting a little more robust