How to use the @converse/headless/log.error function in @converse/headless

To help you get started, we’ve selected a few @converse/headless examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github conversejs / converse.js / src / headless / converse-core.js View on Github external
async function getLoginCredentials () {
    let credentials;
    let wait = 0;
    while (!credentials) {
        try {
            credentials = await fetchLoginCredentials(wait); // eslint-disable-line no-await-in-loop
        } catch (e) {
            log.error('Could not fetch login credentials');
            log.error(e);
        }
        // If unsuccessful, we wait 2 seconds between subsequent attempts to
        // fetch the credentials.
        wait = 2000;
    }
    return credentials;
}
github conversejs / converse.js / src / converse-rosterview.js View on Github external
async removeContact (ev) {
                if (ev && ev.preventDefault) { ev.preventDefault(); }
                if (!_converse.allow_contact_removal) { return; }
                if (!confirm(__("Are you sure you want to remove this contact?"))) { return; }

                try {
                    await this.model.removeFromRoster();
                    this.remove();
                    if (this.model.collection) {
                        // The model might have already been removed as
                        // result of a roster push.
                        this.model.destroy();
                    }
                } catch (e) {
                    log.error(e);
                    _converse.api.alert('error', __('Error'),
                        [__('Sorry, there was an error while trying to remove %1$s as a contact.', this.model.getDisplayName())]
                    );
                }
            },
github conversejs / converse.js / src / headless / converse-vcard.js View on Github external
function getVCardForChatroomOccupant (message) {
            const chatbox = get(message, 'collection.chatbox');
            const nick = Strophe.getResourceFromJid(message.get('from'));

            if (chatbox && chatbox.get('nick') === nick) {
                return _converse.xmppstatus.vcard;
            } else {
                const jid = message.occupant && message.occupant.get('jid') || message.get('from');
                if (jid) {
                    return _converse.vcards.findWhere({jid}) || _converse.vcards.create({jid});
                } else {
                    log.error(`Could not assign VCard for message because no JID found! msgid: ${message.get('msgid')}`);
                    return;
                }
            }
        }
github conversejs / converse.js / src / headless / converse-core.js View on Github external
async function discoverConnectionMethods (domain) {
    const options = {
        'mode': 'cors',
        'headers': {
            'Accept': 'application/xrd+xml, text/xml'
        }
    };
    const url = `https://${domain}/.well-known/host-meta`;
    let response;
    try {
        response = await fetch(url, options);
    } catch (e) {
        log.error(`Failed to discover alternative connection methods at ${url}`);
        log.error(e);
        return;
    }
    if (response.status >= 200 && response.status < 400) {
        await onDomainDiscovered(response);
    } else {
        log.warn("Could not discover XEP-0156 connection methods");
    }
}
github conversejs / converse.js / src / converse-chatview.js View on Github external
(err) => {
                            log.error(err);
                            _converse.api.alert('error', __('Error'), [
                                __('Sorry, there was an error while trying to remove %1$s as a contact.',
                                this.model.contact.getDisplayName())
                            ]);
                        }
                    );
github conversejs / converse.js / src / converse-push.js View on Github external
async function enablePush (domain) {
            domain = domain || _converse.bare_jid;
            const push_enabled = _converse.session.get('push_enabled') || [];
            if (_.includes(push_enabled, domain)) {
                return;
            }
            const enabled_services = _.reject(_converse.push_app_servers, 'disable');
            const disabled_services = _.filter(_converse.push_app_servers, 'disable');
            const enabled = _.map(enabled_services, _.partial(enablePushAppServer, domain));
            const disabled = _.map(disabled_services, _.partial(disablePushAppServer, domain));
            try {
                await Promise.all(enabled.concat(disabled));
            } catch (e) {
                log.error('Could not enable or disable push App Server');
                if (e) log.error(e);
            } finally {
                push_enabled.push(domain);
            }
            _converse.session.save('push_enabled', push_enabled);
        }
        _converse.api.listen.on('statusInitialized', () => enablePush());
github conversejs / converse.js / src / converse-push.js View on Github external
.catch(e => {
                log.error(`Could not disable push app server for ${push_app_server.jid}`);
                log.error(e);
            });
        }
github conversejs / converse.js / src / converse-register.js View on Github external
_onRegisterIQ (stanza) {
                if (stanza.getAttribute("type") === "error") {
                    log.error("Registration failed.");
                    this.reportErrors(stanza);

                    let error = stanza.getElementsByTagName("error");
                    if (error.length !== 1) {
                        _converse.connection._changeConnectStatus(Strophe.Status.REGIFAIL, "unknown");
                        return false;
                    }
                    error = error[0].firstChild.tagName.toLowerCase();
                    if (error === 'conflict') {
                        _converse.connection._changeConnectStatus(Strophe.Status.CONFLICT, error);
                    } else if (error === 'not-acceptable') {
                        _converse.connection._changeConnectStatus(Strophe.Status.NOTACCEPTABLE, error);
                    } else {
                        _converse.connection._changeConnectStatus(Strophe.Status.REGIFAIL, error);
                    }
                } else {