rynex
Version:
A minimalist TypeScript framework for building reactive web applications with no virtual DOM
142 lines • 4.75 kB
TypeScript
/**
* Rynex Error System
* Comprehensive error handling and validation for the framework
*/
export declare enum ErrorSeverity {
WARNING = "warning",
ERROR = "error",
CRITICAL = "critical"
}
export declare enum ErrorCategory {
VALIDATION = "validation",
RUNTIME = "runtime",
DOM = "dom",
STATE = "state",
COMPONENT = "component",
ROUTER = "router",
LIFECYCLE = "lifecycle",
PROPS = "props",
CHILDREN = "children"
}
export declare class RynexError extends Error {
readonly severity: ErrorSeverity;
readonly category: ErrorCategory;
readonly timestamp: number;
readonly context?: any;
constructor(message: string, category: ErrorCategory, severity?: ErrorSeverity, context?: any);
toString(): string;
}
export declare class ValidationError extends RynexError {
constructor(message: string, context?: any);
}
export declare class DOMError extends RynexError {
constructor(message: string, severity?: ErrorSeverity, context?: any);
}
export declare class StateError extends RynexError {
constructor(message: string, context?: any);
}
export declare class ComponentError extends RynexError {
constructor(message: string, severity?: ErrorSeverity, context?: any);
}
export declare class RouterError extends RynexError {
constructor(message: string, context?: any);
}
export declare class LifecycleError extends RynexError {
constructor(message: string, context?: any);
}
interface ErrorHandlerConfig {
onError?: (error: RynexError) => void;
throwOnError?: boolean;
logErrors?: boolean;
captureStackTrace?: boolean;
}
declare class ErrorHandler {
private config;
private errorLog;
private maxLogSize;
configure(config: Partial<ErrorHandlerConfig>): void;
handle(error: RynexError): void;
private getConsoleStyle;
getErrors(): RynexError[];
clearErrors(): void;
getErrorsByCategory(category: ErrorCategory): RynexError[];
getErrorsBySeverity(severity: ErrorSeverity): RynexError[];
}
export declare const errorHandler: ErrorHandler;
export declare const validators: {
/**
* Validate that a value is not null or undefined
*/
required(value: any, fieldName: string, context?: any): void;
/**
* Validate type of a value
*/
type(value: any, expectedType: string, fieldName: string, context?: any): void;
/**
* Validate that value is a function
*/
isFunction(value: any, fieldName: string, context?: any): void;
/**
* Validate that value is an object
*/
isObject(value: any, fieldName: string, context?: any): void;
/**
* Validate that value is an array
*/
isArray(value: any, fieldName: string, context?: any): void;
/**
* Validate that value is a string
*/
isString(value: any, fieldName: string, context?: any): void;
/**
* Validate that value is a number
*/
isNumber(value: any, fieldName: string, context?: any): void;
/**
* Validate that value is a boolean
*/
isBoolean(value: any, fieldName: string, context?: any): void;
/**
* Validate that value is an HTMLElement
*/
isHTMLElement(value: any, fieldName: string, context?: any): void;
/**
* Validate that element exists in DOM
*/
elementExists(element: HTMLElement | null, fieldName: string, context?: any): void;
/**
* Validate that selector is valid
*/
validSelector(selector: string, fieldName: string, context?: any): void;
/**
* Validate that value is one of allowed values
*/
oneOf(value: any, allowedValues: any[], fieldName: string, context?: any): void;
/**
* Validate array is not empty
*/
notEmpty(arr: any[], fieldName: string, context?: any): void;
/**
* Validate string is not empty
*/
notEmptyString(value: string, fieldName: string, context?: any): void;
/**
* Validate number is in range
*/
inRange(value: number, min: number, max: number, fieldName: string, context?: any): void;
/**
* Validate props object
*/
validProps(props: any, fieldName?: string, context?: any): void;
/**
* Validate children
*/
validChildren(children: any, fieldName?: string, context?: any): void;
};
export declare function safeExecute<T>(fn: () => T, errorMessage: string, category?: ErrorCategory, context?: any): T | null;
export declare function setDevelopmentMode(enabled: boolean): void;
export declare function isDevelopmentMode(): boolean;
export declare function devValidate(validationFn: () => void): void;
export declare function assert(condition: boolean, message: string, context?: any): void;
export {};
//# sourceMappingURL=errors.d.ts.map