check error before commit