private function assignExceptions(RequestException $ex)
    {
        if ($ex->hasResponse() && $ex->getResponse()->getStatusCode() == 401) {
            throw new TokenExpiredException('Salesforce token has expired', $ex);
        } elseif ($ex->hasResponse()) {
            throw new SalesforceException('Salesforce response error: '.$ex->getMessage(), $ex);
        } else {
            throw new SalesforceException('Invalid request: %s', $ex);
        }
    }