woodpecker/web/src/compositions/useNotifications.ts
2022-07-17 21:51:10 +02:00

15 lines
516 B
TypeScript

import Notifications, { NotificationsOptions, notify } from '@kyvg/vue3-notification';
export const notifications = Notifications;
function notifyError(err: unknown, args: NotificationsOptions | string = {}): void {
// eslint-disable-next-line no-console
console.error(err);
const mArgs = typeof args === 'string' ? { title: args } : args;
const title = mArgs?.title || (err as Error)?.message || `${err}`;
notify({ type: 'error', ...mArgs, title });
}
export default () => ({ notify, notifyError });