Add error message for missing imports (and possibly other errors)

fixes #7331