Skip to content
Snippets Groups Projects
Commit 00be017d authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire: Committed by Reiter, Christoph
Browse files

Add generic XHR error handling

parent ce22a183
No related branches found
No related tags found
No related merge requests found
import {send as notify} from './notification';
import {i18n} from "./i18n";
export const xhrError = (jqXHR, textStatus, errorThrown) => {
if (textStatus !== "abort") {
let body = jqXHR.responseJSON !== undefined && jqXHR.responseJSON["hydra:description"] !== undefined ?
jqXHR.responseJSON["hydra:description"] : textStatus;
if (jqXHR.status === 0) {
body = i18n.t('error.connection-to-server-refused');
}
notify({
"summary": i18n.t('error.summary'),
"body": body,
"type": "danger",
});
}
};
import {createInstance} from './i18next.js';
import de from './i18n/de/translation.json';
import en from './i18n/en/translation.json';
export const i18n = createInstance({en: en, de: de}, 'de', 'en');
\ No newline at end of file
{
"error": {
"summary": "Ein Fehler ist aufgetreten",
"connection-to-server-refused": "Verbindungs zum Server verweigert!"
}
}
{
"error": {
"summary": "An error occurred",
"connection-to-server-refused": "Connection to server refused!"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment