Improve transaction error handling