throw exception when invalid files are given