removed useless var assignment in exclude_directory function

removed useless variable assignment and changed error handling code