persist errors to db