Added check for invalid use of promise API.