OpenXE/resources/js/ajaxErrorHandler.ts
2023-12-11 11:13:30 +01:00

15 lines
518 B
TypeScript

// 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);
}
}