UNPKG

@codelet/core

Version:
12 lines (11 loc) 539 B
import type { Loose } from '@daysnap/types'; export type WithErrorContext = Loose<{ setData: (data: any) => void; }>; export interface CreateWithOptions { /** 格式化错误消息 */ formatMessage?: (err: unknown) => string; /** 排除指定错误消息 */ excludeMessage?: (message: string) => boolean; } export declare function createWithError(options?: CreateWithOptions): <T extends (...args: any[]) => Promise<any>>(fn: T) => (...params: [...Parameters<T>, WithErrorContext?]) => Promise<Awaited<ReturnType<T>>>;