MCPcopy
hub / github.com/conversejs/converse.js / getErrorAttributes

Function getErrorAttributes

src/headless/shared/parsers.js:293–306  ·  view source on GitHub ↗
(stanza)

Source from the content-addressed store, hash-verified

291 * @param {Element} stanza - The message stanza
292 */
293export function getErrorAttributes(stanza) {
294 if (stanza.getAttribute('type') === 'error') {
295 const error = stanza.querySelector('error');
296 const text = sizzle(`text[xmlns="${Strophe.NS.STANZAS}"]`, error).pop();
297 return {
298 is_error: true,
299 error_text: text?.textContent,
300 error_type: error.getAttribute('type'),
301 error_condition: error.firstElementChild.nodeName,
302 errors: Array.from(error.children).map((e) => ({ name: e.nodeName, xmlns: e.getAttribute('xmlns') })),
303 };
304 }
305 return {};
306}
307
308/**
309 * Given a message stanza, extract XEP-0461 reply attributes

Callers 2

parseMUCMessageFunction · 0.90
parseMessageFunction · 0.90

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected