error handling in readdir