protected static function process_curl_exception($token, $curloutput) {
        if (!isset($curloutput['exception'])) {
            return;
        }
        if ($token === registration::get_token()) {
            // Check if registration token was rejected or there are other problems with registration.
            if (($curloutput['exception'] === 'moodle_exception' && $curloutput['errorcode'] === 'invalidtoken')
                    || $curloutput['exception'] === 'registration_exception') {
                // Force admin to repeat site registration process.
                registration::reset_token();
                throw new moodle_exception('errorwstokenreset', 'hub', '', $curloutput['message']);
            }
        }
        throw new moodle_exception('errorws', 'hub', '', $curloutput['message']);
    }