handle errors and reset cwd on next build