Commit 299fa4f3 authored by JC Brand's avatar JC Brand

Nicer error logging when translations are not found

parent e123c690
...@@ -69476,8 +69476,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -69476,8 +69476,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* Parameters: * Parameters:
* (XMLElement) stanza - The incoming message stanza * (XMLElement) stanza - The incoming message stanza
*/ */
let from_jid = stanza.getAttribute('from'), let to_jid = stanza.getAttribute('to');
to_jid = stanza.getAttribute('to');
const to_resource = Strophe.getResourceFromJid(to_jid); const to_resource = Strophe.getResourceFromJid(to_jid);
if (_converse.filter_by_resource && to_resource && to_resource !== _converse.resource) { if (_converse.filter_by_resource && to_resource && to_resource !== _converse.resource) {
...@@ -69488,11 +69487,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -69488,11 +69487,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// XXX: Ideally we wouldn't have to check for headline // XXX: Ideally we wouldn't have to check for headline
// messages, but Prosody sends headline messages with the // messages, but Prosody sends headline messages with the
// wrong type ('chat'), so we need to filter them out here. // wrong type ('chat'), so we need to filter them out here.
_converse.log(`onMessage: Ignoring incoming headline message sent with type 'chat' from JID: ${from_jid}`, Strophe.LogLevel.INFO); _converse.log(`onMessage: Ignoring incoming headline message sent with type 'chat' from JID: ${stanza.getAttribute('from')}`, Strophe.LogLevel.INFO);
return true; return true;
} }
let from_jid = stanza.getAttribute('from');
const forwarded = stanza.querySelector('forwarded'), const forwarded = stanza.querySelector('forwarded'),
original_stanza = stanza; original_stanza = stanza;
...@@ -69519,6 +69519,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -69519,6 +69519,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
if (is_me) { if (is_me) {
// I am the sender, so this must be a forwarded message... // I am the sender, so this must be a forwarded message...
if (_.isNull(to_jid)) {
return _converse.log(`Don't know how to handle message stanza without 'to' attribute. ${stanza.outerHTML}`, Strophe.LogLevel.ERROR);
}
contact_jid = Strophe.getBareJidFromJid(to_jid); contact_jid = Strophe.getBareJidFromJid(to_jid);
} else { } else {
contact_jid = from_bare_jid; contact_jid = from_bare_jid;
...@@ -73139,7 +73143,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -73139,7 +73143,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
} else { } else {
i18n.fetchTranslations(_converse.locale, _converse.locales, u.interpolate(_converse.locales_url, { i18n.fetchTranslations(_converse.locale, _converse.locales, u.interpolate(_converse.locales_url, {
'locale': _converse.locale 'locale': _converse.locale
})).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)).then(finishInitialization).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); })).catch(e => _converse.log(e.message, Strophe.LogLevel.FATAL)).then(finishInitialization).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
} }
return init_promise; return init_promise;
...@@ -84619,8 +84623,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -84619,8 +84623,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
} }
}; };
xhr.onerror = function () { xhr.onerror = e => {
reject(xhr.statusText); const err_message = e ? ` Error: ${e.message}` : '';
reject(new Error(`Could not fetch translations. Status: ${xhr.statusText}. ${err_message}`));
}; };
xhr.send(); xhr.send();
...@@ -667,8 +667,7 @@ ...@@ -667,8 +667,7 @@
* Parameters: * Parameters:
* (XMLElement) stanza - The incoming message stanza * (XMLElement) stanza - The incoming message stanza
*/ */
let from_jid = stanza.getAttribute('from'), let to_jid = stanza.getAttribute('to');
to_jid = stanza.getAttribute('to');
const to_resource = Strophe.getResourceFromJid(to_jid); const to_resource = Strophe.getResourceFromJid(to_jid);
if (_converse.filter_by_resource && (to_resource && to_resource !== _converse.resource)) { if (_converse.filter_by_resource && (to_resource && to_resource !== _converse.resource)) {
...@@ -682,12 +681,13 @@ ...@@ -682,12 +681,13 @@
// messages, but Prosody sends headline messages with the // messages, but Prosody sends headline messages with the
// wrong type ('chat'), so we need to filter them out here. // wrong type ('chat'), so we need to filter them out here.
_converse.log( _converse.log(
`onMessage: Ignoring incoming headline message sent with type 'chat' from JID: ${from_jid}`, `onMessage: Ignoring incoming headline message sent with type 'chat' from JID: ${stanza.getAttribute('from')}`,
Strophe.LogLevel.INFO Strophe.LogLevel.INFO
); );
return true; return true;
} }
let from_jid = stanza.getAttribute('from');
const forwarded = stanza.querySelector('forwarded'), const forwarded = stanza.querySelector('forwarded'),
original_stanza = stanza; original_stanza = stanza;
...@@ -713,6 +713,12 @@ ...@@ -713,6 +713,12 @@
let contact_jid; let contact_jid;
if (is_me) { if (is_me) {
// I am the sender, so this must be a forwarded message... // I am the sender, so this must be a forwarded message...
if (_.isNull(to_jid)) {
return _converse.log(
`Don't know how to handle message stanza without 'to' attribute. ${stanza.outerHTML}`,
Strophe.LogLevel.ERROR
);
}
contact_jid = Strophe.getBareJidFromJid(to_jid); contact_jid = Strophe.getBareJidFromJid(to_jid);
} else { } else {
contact_jid = from_bare_jid; contact_jid = from_bare_jid;
......
...@@ -1189,7 +1189,7 @@ ...@@ -1189,7 +1189,7 @@
_converse.locale, _converse.locale,
_converse.locales, _converse.locales,
u.interpolate(_converse.locales_url, {'locale': _converse.locale})) u.interpolate(_converse.locales_url, {'locale': _converse.locale}))
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)) .catch(e => _converse.log(e.message, Strophe.LogLevel.FATAL))
.then(finishInitialization) .then(finishInitialization)
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); .catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
} }
......
...@@ -159,9 +159,10 @@ ...@@ -159,9 +159,10 @@
xhr.onerror(); xhr.onerror();
} }
}; };
xhr.onerror = function () { xhr.onerror = (e) => {
reject(xhr.statusText); const err_message = e ? ` Error: ${e.message}` : '';
}; reject(new Error(`Could not fetch translations. Status: ${xhr.statusText}. ${err_message}`));
}
xhr.send(); xhr.send();
}); });
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment