Handle errors in databases