add sql printing in case of error