Catch errors when dealing with input data (#1788)

fixes #1788