Make sure errors are caught and passed to the promise handler.