Improved promise error handling.