Fix error handing when directory is not created