Raise error on failed insert or fetch