@tachui/devtools
Version:
Development & debugging tools for tachUI framework
186 lines • 5.14 kB
TypeScript
/**
* Enhanced Error Reporting System - Phase 1C
*
* Rich error message templates, contextual suggestions, fix examples,
* and comprehensive developer guidance for validation errors.
*/
import type { RecoveryStrategy } from './enhanced-runtime';
import { EnhancedValidationError } from './enhanced-runtime';
/**
* Error severity levels
*/
export type ValidationErrorSeverity = 'critical' | 'error' | 'warning' | 'info';
/**
* Error category for classification
*/
export type ValidationErrorCategory = 'component-construction' | 'modifier-usage' | 'prop-validation' | 'lifecycle' | 'performance' | 'accessibility' | 'best-practices';
/**
* Fix suggestion with automated repair capability
*/
export interface FixSuggestion {
description: string;
code: string;
autoFix?: () => string;
difficulty: 'easy' | 'medium' | 'hard';
}
/**
* Enhanced error context with rich metadata
*/
export interface EnhancedErrorContext {
component: string;
package?: string;
property?: string;
category: ValidationErrorCategory;
severity: ValidationErrorSeverity;
errorCode: string;
suggestion: string;
documentation: string;
fixes: FixSuggestion[];
examples: {
wrong: string[];
correct: string[];
};
recoveryStrategy: RecoveryStrategy;
fallbackValue?: any;
autoFix?: () => any;
location?: {
file?: string;
line?: number;
column?: number;
};
relatedErrors?: string[];
commonMistakes?: string[];
}
/**
* Error message template for consistent formatting
*/
export interface ErrorMessageTemplate {
title: string;
description: string;
impact: string;
quickFix?: string;
detailedSolution?: string;
prevention?: string;
emoji: string;
color: 'red' | 'yellow' | 'blue' | 'gray';
}
/**
* Comprehensive error templates database
*/
export declare const ErrorTemplates: Record<string, ErrorMessageTemplate>;
/**
* Error code generator for consistent error identification
*/
export declare class ErrorCodeGenerator {
private static categories;
static generate(category: ValidationErrorCategory, component: string, specific?: string): string;
}
/**
* Enhanced error reporter with rich formatting
*/
export declare class EnhancedErrorReporter {
private static instance;
private errorHistory;
private maxHistorySize;
static getInstance(): EnhancedErrorReporter;
/**
* Create enhanced validation error with rich context
*/
createError(message: string, context: Partial<EnhancedErrorContext>): EnhancedValidationError;
/**
* Format error message with rich context
*/
formatError(error: EnhancedValidationError): string;
/**
* Get error template by code or fallback to default
*/
private getTemplate;
/**
* Substitute variables in template strings
*/
private substituteVariables;
/**
* Get recovery strategy description
*/
private getRecoveryDescription;
/**
* Record error in history for analytics
*/
private recordError;
/**
* Get error statistics
*/
getErrorStats(): {
totalErrors: number;
categories: {
[k: string]: number;
};
severities: {
[k: string]: number;
};
components: {
[k: string]: number;
};
recentErrors: {
code: string;
component: string;
message: string;
timestamp: number;
}[];
};
/**
* Clear error history
*/
clearHistory(): void;
/**
* Export error report for debugging
*/
exportErrorReport(): string;
}
/**
* Error suggestion engine for intelligent fixes
*/
export declare class ErrorSuggestionEngine {
/**
* Generate fix suggestions for common component errors
*/
static generateComponentFixSuggestions(component: string, error: string, _args: unknown[]): FixSuggestion[];
/**
* Generate fix for missing parameters
*/
private static generateParameterFix;
/**
* Generate fix for type mismatches
*/
private static generateTypeFix;
/**
* Generate fix for null/undefined values
*/
private static generateNullCheckFix;
}
export declare const errorReporter: EnhancedErrorReporter;
export declare const ErrorReportingUtils: {
createError: (message: string, context: Partial<EnhancedErrorContext>) => EnhancedValidationError;
formatError: (error: EnhancedValidationError) => string;
getStats: () => {
totalErrors: number;
categories: {
[k: string]: number;
};
severities: {
[k: string]: number;
};
components: {
[k: string]: number;
};
recentErrors: {
code: string;
component: string;
message: string;
timestamp: number;
}[];
};
exportReport: () => string;
generateSuggestions: typeof ErrorSuggestionEngine.generateComponentFixSuggestions;
};
//# sourceMappingURL=error-reporting.d.ts.map