Files
lucia-frontend/src/module/apiError.js
T
2026-03-08 12:11:57 +08:00

24 lines
838 B
JavaScript

// The Lucia project.
// Copyright 2023-2026 DSP, inc. All rights reserved.
// Authors:
// chiayin.kuo@dsp.im (chiayin), 2023/1/31
// imacat.yang@dsp.im (imacat), 2023/9/23
// cindy.chang@dsp.im (Cindy Chang), 2024/5/30
/** @module apiError Centralized API error handler with toast notifications. */
import { useToast } from "vue-toast-notification";
import "vue-toast-notification/dist/theme-sugar.css";
/**
* Handles API errors by showing a toast notification.
* 401 errors are handled by the axios response interceptor
* in api/client.js.
*
* @param {Object} error - The error object from the API call.
* @param {string} toastMessage - The message to display in the toast.
*/
export default function apiError(error, toastMessage) {
const $toast = useToast();
$toast.default(toastMessage, { position: "bottom" });
}