Bug fix: Fixed handleAPIError to return proper exception message.