@httpc/kit
Version:
httpc toolbox for building function-based API with minimal code and end-to-end type safety
15 lines (14 loc) • 816 B
TypeScript
import { HttpCallError, ErrorInfo } from "@httpc/server";
export declare class ServiceError extends HttpCallError {
constructor(errorCode: string, data?: Record<string, any>);
constructor(errorCode: string, message?: string, data?: Record<string, any>);
constructor(errorInfo: ErrorInfo);
}
export declare class ServiceErrorPresets<T extends string = ""> {
protected readonly map: Map<string, ErrorInfo>;
constructor(map?: Map<string, ErrorInfo>);
add<E extends string>(errorCode: E, errorInfo?: Omit<ErrorInfo, "errorCode">): ServiceErrorPresets<T | E>;
get(errorCode: T): ErrorInfo | undefined;
get(errorCode: string): ErrorInfo | undefined;
}
export type ServiceErrors<T extends ServiceErrorPresets> = T extends ServiceErrorPresets<infer U> ? Exclude<U, ""> : never;