@kitiumai/utils-ts
Version:
Comprehensive TypeScript utilities for KitiumAI projects
49 lines • 1.36 kB
TypeScript
import type { ErrorStrategy } from './result.js';
/**
* Utility-specific error codes
*/
export type UtilsErrorCode = 'INVALID_CHUNK_SIZE' | 'GROUP_BY_KEY_MISSING' | 'INVALID_ARGUMENT' | 'OPERATION_FAILED';
/**
* Error initialization options for utility errors
*/
export interface UtilsErrorInit {
code: UtilsErrorCode;
message: string;
details?: Record<string, unknown>;
cause?: unknown;
}
/**
* Base error class for utils-ts package
*/
export declare class UtilsError extends Error {
readonly code: UtilsErrorCode;
readonly details: Record<string, unknown> | undefined;
constructor(init: UtilsErrorInit);
/**
* Convert to JSON representation
*/
toJSON(): Record<string, unknown>;
}
/**
* Create a utility error
*/
export declare const createUtilsError: (init: UtilsErrorInit) => UtilsError;
/**
* Error handling options for utilities
*/
export interface ErrorHandlingOptions {
onError?: ErrorStrategy;
}
/**
* Check if an error is a UtilsError
*/
export declare function isUtilsError(error: unknown): error is UtilsError;
/**
* Extract error message from unknown error
*/
export declare function getErrorMessage(error: unknown): string;
/**
* Extract error stack from unknown error
*/
export declare function getErrorStack(error: unknown): string | undefined;
//# sourceMappingURL=error.d.ts.map