I don't think this is the correct solution. Whether the directory exist or not shouldn't ever cause a crash. If it does, that's a bug elsewhere.