prisma-zod-generator
Version:
Prisma 2+ generator to emit Zod schemas from your Prisma schema
62 lines (61 loc) • 2.31 kB
TypeScript
/**
* Standardized error handling utilities for PZG Pro
*/
export declare class PZGProError extends Error {
readonly code: string;
readonly feature: string;
readonly context?: Record<string, unknown> | undefined;
constructor(message: string, code: string, feature: string, context?: Record<string, unknown> | undefined);
}
export declare class LicenseError extends PZGProError {
constructor(message: string, context?: Record<string, unknown>);
}
export declare class ValidationError extends PZGProError {
constructor(message: string, feature: string, context?: Record<string, unknown>);
}
export declare class FileSystemError extends PZGProError {
constructor(message: string, feature: string, context?: Record<string, unknown>);
}
export declare class SecurityError extends PZGProError {
constructor(message: string, feature: string, context?: Record<string, unknown>);
}
/**
* Safe async wrapper that handles errors consistently
*/
export declare function safeAsync<T>(operation: () => Promise<T>, feature: string, context?: Record<string, unknown>): Promise<{
success: true;
data: T;
} | {
success: false;
error: PZGProError;
}>;
/**
* Safe sync wrapper that handles errors consistently
*/
export declare function safeSync<T>(operation: () => T, feature: string, context?: Record<string, unknown>): {
success: true;
data: T;
} | {
success: false;
error: PZGProError;
};
/**
* Retry wrapper for operations that may fail temporarily
*/
export declare function withRetry<T>(operation: () => Promise<T>, maxAttempts?: number, delayMs?: number, feature?: string): Promise<T>;
/**
* Validate that a value is not null or undefined
*/
export declare function assertDefined<T>(value: T | null | undefined, message: string, feature: string): asserts value is T;
/**
* Validate that a string is not empty
*/
export declare function assertNonEmpty(value: string | null | undefined, message: string, feature: string): asserts value is string;
/**
* Safe file operation wrapper
*/
export declare function safeFileOperation<T>(operation: () => Promise<T> | T, filePath: string, feature: string): Promise<T>;
/**
* Production-safe logger that doesn't expose sensitive information
*/
export declare function logError(error: PZGProError): void;