OpenXE/resources/js/ajaxErrorHandler.ts

15 lines
518 B
TypeScript
Raw Normal View History

2023-03-30 10:54:18 +02:00
// SPDX-FileCopyrightText: 2023 Andreas Palm
//
// SPDX-License-Identifier: AGPL-3.0-only
import {AxiosError} from 'axios';
export function AlertErrorHandler(error: AxiosError) {
if (error.response === undefined || error.response.status >= 500) {
console.log('Unknown error on axios request', error);
alert('Unerwarteter Fehler, weitere Hinweise ggf. in der JavaScript-Konsole');
} else {
console.log('ClientError on axios request', error);
alert(error.response.data);
}
}