modestbench 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/LICENSE.md +55 -0
- package/README.md +699 -0
- package/dist/bootstrap.cjs +37 -0
- package/dist/bootstrap.cjs.map +1 -0
- package/dist/bootstrap.d.cts +17 -0
- package/dist/bootstrap.d.cts.map +1 -0
- package/dist/bootstrap.d.ts +17 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +33 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/cli/commands/history.cjs +459 -0
- package/dist/cli/commands/history.cjs.map +1 -0
- package/dist/cli/commands/history.d.cts +34 -0
- package/dist/cli/commands/history.d.cts.map +1 -0
- package/dist/cli/commands/history.d.ts +34 -0
- package/dist/cli/commands/history.d.ts.map +1 -0
- package/dist/cli/commands/history.js +422 -0
- package/dist/cli/commands/history.js.map +1 -0
- package/dist/cli/commands/init.cjs +566 -0
- package/dist/cli/commands/init.cjs.map +1 -0
- package/dist/cli/commands/init.d.cts +26 -0
- package/dist/cli/commands/init.d.cts.map +1 -0
- package/dist/cli/commands/init.d.ts +26 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +562 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/run.cjs +285 -0
- package/dist/cli/commands/run.cjs.map +1 -0
- package/dist/cli/commands/run.d.cts +37 -0
- package/dist/cli/commands/run.d.cts.map +1 -0
- package/dist/cli/commands/run.d.ts +37 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +248 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/index.cjs +523 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +58 -0
- package/dist/cli/index.d.cts.map +1 -0
- package/dist/cli/index.d.ts +58 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +515 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/manager.cjs +370 -0
- package/dist/config/manager.cjs.map +1 -0
- package/dist/config/manager.d.cts +46 -0
- package/dist/config/manager.d.cts.map +1 -0
- package/dist/config/manager.d.ts +46 -0
- package/dist/config/manager.d.ts.map +1 -0
- package/dist/config/manager.js +333 -0
- package/dist/config/manager.js.map +1 -0
- package/dist/config/schema.cjs +182 -0
- package/dist/config/schema.cjs.map +1 -0
- package/dist/config/schema.d.cts +51 -0
- package/dist/config/schema.d.cts.map +1 -0
- package/dist/config/schema.d.ts +51 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +145 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/constants.cjs +22 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +10 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +19 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/benchmark-schema.cjs +135 -0
- package/dist/core/benchmark-schema.cjs.map +1 -0
- package/dist/core/benchmark-schema.d.cts +139 -0
- package/dist/core/benchmark-schema.d.cts.map +1 -0
- package/dist/core/benchmark-schema.d.ts +139 -0
- package/dist/core/benchmark-schema.d.ts.map +1 -0
- package/dist/core/benchmark-schema.js +132 -0
- package/dist/core/benchmark-schema.js.map +1 -0
- package/dist/core/engine.cjs +669 -0
- package/dist/core/engine.cjs.map +1 -0
- package/dist/core/engine.d.cts +128 -0
- package/dist/core/engine.d.cts.map +1 -0
- package/dist/core/engine.d.ts +128 -0
- package/dist/core/engine.d.ts.map +1 -0
- package/dist/core/engine.js +632 -0
- package/dist/core/engine.js.map +1 -0
- package/dist/core/engines/accurate-engine.cjs +292 -0
- package/dist/core/engines/accurate-engine.cjs.map +1 -0
- package/dist/core/engines/accurate-engine.d.cts +63 -0
- package/dist/core/engines/accurate-engine.d.cts.map +1 -0
- package/dist/core/engines/accurate-engine.d.ts +63 -0
- package/dist/core/engines/accurate-engine.d.ts.map +1 -0
- package/dist/core/engines/accurate-engine.js +288 -0
- package/dist/core/engines/accurate-engine.js.map +1 -0
- package/dist/core/engines/index.cjs +21 -0
- package/dist/core/engines/index.cjs.map +1 -0
- package/dist/core/engines/index.d.cts +16 -0
- package/dist/core/engines/index.d.cts.map +1 -0
- package/dist/core/engines/index.d.ts +16 -0
- package/dist/core/engines/index.d.ts.map +1 -0
- package/dist/core/engines/index.js +16 -0
- package/dist/core/engines/index.js.map +1 -0
- package/dist/core/engines/tinybench-engine.cjs +286 -0
- package/dist/core/engines/tinybench-engine.cjs.map +1 -0
- package/dist/core/engines/tinybench-engine.d.cts +18 -0
- package/dist/core/engines/tinybench-engine.d.cts.map +1 -0
- package/dist/core/engines/tinybench-engine.d.ts +18 -0
- package/dist/core/engines/tinybench-engine.d.ts.map +1 -0
- package/dist/core/engines/tinybench-engine.js +282 -0
- package/dist/core/engines/tinybench-engine.js.map +1 -0
- package/dist/core/error-manager.cjs +303 -0
- package/dist/core/error-manager.cjs.map +1 -0
- package/dist/core/error-manager.d.cts +77 -0
- package/dist/core/error-manager.d.cts.map +1 -0
- package/dist/core/error-manager.d.ts +77 -0
- package/dist/core/error-manager.d.ts.map +1 -0
- package/dist/core/error-manager.js +299 -0
- package/dist/core/error-manager.js.map +1 -0
- package/dist/core/loader.cjs +287 -0
- package/dist/core/loader.cjs.map +1 -0
- package/dist/core/loader.d.cts +55 -0
- package/dist/core/loader.d.cts.map +1 -0
- package/dist/core/loader.d.ts +55 -0
- package/dist/core/loader.d.ts.map +1 -0
- package/dist/core/loader.js +250 -0
- package/dist/core/loader.js.map +1 -0
- package/dist/core/stats-utils.cjs +99 -0
- package/dist/core/stats-utils.cjs.map +1 -0
- package/dist/core/stats-utils.d.cts +50 -0
- package/dist/core/stats-utils.d.cts.map +1 -0
- package/dist/core/stats-utils.d.ts +50 -0
- package/dist/core/stats-utils.d.ts.map +1 -0
- package/dist/core/stats-utils.js +94 -0
- package/dist/core/stats-utils.js.map +1 -0
- package/dist/index.cjs +64 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +22 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/progress/manager.cjs +325 -0
- package/dist/progress/manager.cjs.map +1 -0
- package/dist/progress/manager.d.cts +125 -0
- package/dist/progress/manager.d.cts.map +1 -0
- package/dist/progress/manager.d.ts +125 -0
- package/dist/progress/manager.d.ts.map +1 -0
- package/dist/progress/manager.js +321 -0
- package/dist/progress/manager.js.map +1 -0
- package/dist/reporters/csv.cjs +250 -0
- package/dist/reporters/csv.cjs.map +1 -0
- package/dist/reporters/csv.d.cts +92 -0
- package/dist/reporters/csv.d.cts.map +1 -0
- package/dist/reporters/csv.d.ts +92 -0
- package/dist/reporters/csv.d.ts.map +1 -0
- package/dist/reporters/csv.js +246 -0
- package/dist/reporters/csv.js.map +1 -0
- package/dist/reporters/human.cjs +516 -0
- package/dist/reporters/human.cjs.map +1 -0
- package/dist/reporters/human.d.cts +86 -0
- package/dist/reporters/human.d.cts.map +1 -0
- package/dist/reporters/human.d.ts +86 -0
- package/dist/reporters/human.d.ts.map +1 -0
- package/dist/reporters/human.js +509 -0
- package/dist/reporters/human.js.map +1 -0
- package/dist/reporters/index.cjs +17 -0
- package/dist/reporters/index.cjs.map +1 -0
- package/dist/reporters/index.d.cts +10 -0
- package/dist/reporters/index.d.cts.map +1 -0
- package/dist/reporters/index.d.ts +10 -0
- package/dist/reporters/index.d.ts.map +1 -0
- package/dist/reporters/index.js +10 -0
- package/dist/reporters/index.js.map +1 -0
- package/dist/reporters/json.cjs +215 -0
- package/dist/reporters/json.cjs.map +1 -0
- package/dist/reporters/json.d.cts +79 -0
- package/dist/reporters/json.d.cts.map +1 -0
- package/dist/reporters/json.d.ts +79 -0
- package/dist/reporters/json.d.ts.map +1 -0
- package/dist/reporters/json.js +211 -0
- package/dist/reporters/json.js.map +1 -0
- package/dist/reporters/registry.cjs +255 -0
- package/dist/reporters/registry.cjs.map +1 -0
- package/dist/reporters/registry.d.cts +155 -0
- package/dist/reporters/registry.d.cts.map +1 -0
- package/dist/reporters/registry.d.ts +155 -0
- package/dist/reporters/registry.d.ts.map +1 -0
- package/dist/reporters/registry.js +249 -0
- package/dist/reporters/registry.js.map +1 -0
- package/dist/reporters/simple.cjs +328 -0
- package/dist/reporters/simple.cjs.map +1 -0
- package/dist/reporters/simple.d.cts +51 -0
- package/dist/reporters/simple.d.cts.map +1 -0
- package/dist/reporters/simple.d.ts +51 -0
- package/dist/reporters/simple.d.ts.map +1 -0
- package/dist/reporters/simple.js +321 -0
- package/dist/reporters/simple.js.map +1 -0
- package/dist/schema/modestbench-config.schema.json +162 -0
- package/dist/storage/history.cjs +456 -0
- package/dist/storage/history.cjs.map +1 -0
- package/dist/storage/history.d.cts +99 -0
- package/dist/storage/history.d.cts.map +1 -0
- package/dist/storage/history.d.ts +99 -0
- package/dist/storage/history.d.ts.map +1 -0
- package/dist/storage/history.js +452 -0
- package/dist/storage/history.js.map +1 -0
- package/dist/types/cli.cjs +21 -0
- package/dist/types/cli.cjs.map +1 -0
- package/dist/types/cli.d.cts +296 -0
- package/dist/types/cli.d.cts.map +1 -0
- package/dist/types/cli.d.ts +296 -0
- package/dist/types/cli.d.ts.map +1 -0
- package/dist/types/cli.js +18 -0
- package/dist/types/cli.js.map +1 -0
- package/dist/types/core.cjs +14 -0
- package/dist/types/core.cjs.map +1 -0
- package/dist/types/core.d.cts +380 -0
- package/dist/types/core.d.cts.map +1 -0
- package/dist/types/core.d.ts +380 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +13 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/index.cjs +27 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +11 -0
- package/dist/types/index.d.cts.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/interfaces.cjs +10 -0
- package/dist/types/interfaces.cjs.map +1 -0
- package/dist/types/interfaces.d.cts +381 -0
- package/dist/types/interfaces.d.cts.map +1 -0
- package/dist/types/interfaces.d.ts +381 -0
- package/dist/types/interfaces.d.ts.map +1 -0
- package/dist/types/interfaces.js +9 -0
- package/dist/types/interfaces.js.map +1 -0
- package/dist/types/utility.cjs +92 -0
- package/dist/types/utility.cjs.map +1 -0
- package/dist/types/utility.d.cts +330 -0
- package/dist/types/utility.d.cts.map +1 -0
- package/dist/types/utility.d.ts +330 -0
- package/dist/types/utility.d.ts.map +1 -0
- package/dist/types/utility.js +78 -0
- package/dist/types/utility.js.map +1 -0
- package/package.json +211 -0
- package/src/bootstrap.ts +35 -0
- package/src/cli/commands/history.ts +569 -0
- package/src/cli/commands/init.ts +658 -0
- package/src/cli/commands/run.ts +346 -0
- package/src/cli/index.ts +642 -0
- package/src/config/manager.ts +387 -0
- package/src/config/schema.ts +188 -0
- package/src/constants.ts +21 -0
- package/src/core/benchmark-schema.ts +185 -0
- package/src/core/engine.ts +888 -0
- package/src/core/engines/accurate-engine.ts +408 -0
- package/src/core/engines/index.ts +16 -0
- package/src/core/engines/tinybench-engine.ts +335 -0
- package/src/core/error-manager.ts +372 -0
- package/src/core/loader.ts +324 -0
- package/src/core/stats-utils.ts +135 -0
- package/src/index.ts +46 -0
- package/src/progress/manager.ts +415 -0
- package/src/reporters/csv.ts +368 -0
- package/src/reporters/human.ts +707 -0
- package/src/reporters/index.ts +10 -0
- package/src/reporters/json.ts +302 -0
- package/src/reporters/registry.ts +349 -0
- package/src/reporters/simple.ts +459 -0
- package/src/storage/history.ts +600 -0
- package/src/types/cli.ts +312 -0
- package/src/types/core.ts +414 -0
- package/src/types/index.ts +18 -0
- package/src/types/interfaces.ts +451 -0
- package/src/types/utility.ts +446 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ModestBench Error Manager
|
|
4
|
+
*
|
|
5
|
+
* Handles execution errors with context tracking, categorization, and provides
|
|
6
|
+
* structured error information for graceful degradation.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ModestBenchErrorManager = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Error code mappings for different error types and contexts
|
|
12
|
+
*/
|
|
13
|
+
const ERROR_CODES = {
|
|
14
|
+
// Benchmark file errors
|
|
15
|
+
BENCH_001: 'Benchmark file syntax error',
|
|
16
|
+
BENCH_002: 'Invalid benchmark structure',
|
|
17
|
+
BENCH_003: 'Missing dependency',
|
|
18
|
+
BENCH_004: 'Timeout exceeded',
|
|
19
|
+
BENCH_005: 'Memory limit exceeded',
|
|
20
|
+
// Configuration errors
|
|
21
|
+
CONFIG_001: 'Invalid configuration file',
|
|
22
|
+
CONFIG_002: 'Missing required option',
|
|
23
|
+
// Execution errors
|
|
24
|
+
EXEC_001: 'Task execution failed',
|
|
25
|
+
EXEC_002: 'Setup function failed',
|
|
26
|
+
EXEC_003: 'Teardown function failed',
|
|
27
|
+
EXEC_004: 'Memory leak detected',
|
|
28
|
+
// File system errors
|
|
29
|
+
FILE_001: 'File not found',
|
|
30
|
+
FILE_002: 'Permission denied',
|
|
31
|
+
FILE_003: 'Invalid file format',
|
|
32
|
+
// History storage errors
|
|
33
|
+
HIST_001: 'History data corruption',
|
|
34
|
+
HIST_002: 'Disk space insufficient',
|
|
35
|
+
HIST_003: 'Index corruption',
|
|
36
|
+
// System errors
|
|
37
|
+
SYS_001: 'Out of memory',
|
|
38
|
+
SYS_002: 'Process crashed',
|
|
39
|
+
SYS_003: 'System resource unavailable',
|
|
40
|
+
// Unknown errors
|
|
41
|
+
UNKNOWN: 'Unknown error',
|
|
42
|
+
// Validation errors
|
|
43
|
+
VALID_001: 'Schema validation failed',
|
|
44
|
+
VALID_002: 'Type validation failed',
|
|
45
|
+
VALID_003: 'Range validation failed',
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Recoverable error types that shouldn't stop entire execution
|
|
49
|
+
*/
|
|
50
|
+
const RECOVERABLE_ERRORS = new Set([
|
|
51
|
+
'BENCH_003', // Missing dependency (can skip specific benchmark)
|
|
52
|
+
'EXEC_001', // Task execution failed (can continue with other tasks)
|
|
53
|
+
'FILE_001', // File not found (can continue with other files)
|
|
54
|
+
'VALID_002', // Type validation failed (can skip invalid items)
|
|
55
|
+
'VALID_003', // Range validation failed (can skip invalid items)
|
|
56
|
+
]);
|
|
57
|
+
/**
|
|
58
|
+
* Default error manager implementation
|
|
59
|
+
*/
|
|
60
|
+
class ModestBenchErrorManager {
|
|
61
|
+
errors = [];
|
|
62
|
+
handlers = [];
|
|
63
|
+
maxRecentErrors = 50;
|
|
64
|
+
/**
|
|
65
|
+
* Clear error history
|
|
66
|
+
*/
|
|
67
|
+
clearStats() {
|
|
68
|
+
this.errors = [];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Format error for display
|
|
72
|
+
*/
|
|
73
|
+
formatError(error) {
|
|
74
|
+
const { code, context, message } = error;
|
|
75
|
+
let formatted = `[${code}] ${message}`;
|
|
76
|
+
// Add context information
|
|
77
|
+
const contextParts = [];
|
|
78
|
+
if (context.file) {
|
|
79
|
+
contextParts.push(`file: ${context.file}`);
|
|
80
|
+
}
|
|
81
|
+
if (context.suite) {
|
|
82
|
+
contextParts.push(`suite: ${context.suite}`);
|
|
83
|
+
}
|
|
84
|
+
if (context.task) {
|
|
85
|
+
contextParts.push(`task: ${context.task}`);
|
|
86
|
+
}
|
|
87
|
+
if (contextParts.length > 0) {
|
|
88
|
+
formatted += ` (${contextParts.join(', ')})`;
|
|
89
|
+
}
|
|
90
|
+
formatted += ` at ${context.timestamp.toISOString()}`;
|
|
91
|
+
return formatted;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get error code for a given error
|
|
95
|
+
*/
|
|
96
|
+
getErrorCode(error, context) {
|
|
97
|
+
// Check for specific error patterns
|
|
98
|
+
const message = error.message.toLowerCase();
|
|
99
|
+
const name = error.name.toLowerCase();
|
|
100
|
+
// File system errors
|
|
101
|
+
if (message.includes('enoent') || message.includes('no such file')) {
|
|
102
|
+
return 'FILE_001';
|
|
103
|
+
}
|
|
104
|
+
if (message.includes('eacces') || message.includes('permission denied')) {
|
|
105
|
+
return 'FILE_002';
|
|
106
|
+
}
|
|
107
|
+
// Memory errors
|
|
108
|
+
if (message.includes('out of memory') || name.includes('rangeerror')) {
|
|
109
|
+
return 'SYS_001';
|
|
110
|
+
}
|
|
111
|
+
// Timeout errors
|
|
112
|
+
if (message.includes('timeout') || name.includes('timeout')) {
|
|
113
|
+
return 'BENCH_004';
|
|
114
|
+
}
|
|
115
|
+
// Syntax errors in benchmark files
|
|
116
|
+
if (name.includes('syntaxerror') && context.phase === 'loading') {
|
|
117
|
+
return 'BENCH_001';
|
|
118
|
+
}
|
|
119
|
+
// Validation errors
|
|
120
|
+
if (context.phase === 'validation') {
|
|
121
|
+
if (message.includes('schema') || message.includes('structure')) {
|
|
122
|
+
return 'VALID_001';
|
|
123
|
+
}
|
|
124
|
+
if (message.includes('type')) {
|
|
125
|
+
return 'VALID_002';
|
|
126
|
+
}
|
|
127
|
+
if (message.includes('range') || message.includes('limit')) {
|
|
128
|
+
return 'VALID_003';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// Configuration errors
|
|
132
|
+
if (context.phase === 'discovery' && message.includes('config')) {
|
|
133
|
+
return 'CONFIG_001';
|
|
134
|
+
}
|
|
135
|
+
// Execution phase errors
|
|
136
|
+
if (context.phase === 'execution') {
|
|
137
|
+
if (context.task) {
|
|
138
|
+
return 'EXEC_001';
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (context.phase === 'setup') {
|
|
142
|
+
return 'EXEC_002';
|
|
143
|
+
}
|
|
144
|
+
if (context.phase === 'teardown') {
|
|
145
|
+
return 'EXEC_003';
|
|
146
|
+
}
|
|
147
|
+
// Storage errors
|
|
148
|
+
if (message.includes('disk') && message.includes('space')) {
|
|
149
|
+
return 'HIST_002';
|
|
150
|
+
}
|
|
151
|
+
if (message.includes('corrupt') || message.includes('invalid json')) {
|
|
152
|
+
return 'HIST_001';
|
|
153
|
+
}
|
|
154
|
+
// Default to unknown
|
|
155
|
+
return 'UNKNOWN';
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get error count by phase
|
|
159
|
+
*/
|
|
160
|
+
getErrorCountByPhase(phase) {
|
|
161
|
+
return this.errors.filter((error) => error.context.phase === phase).length;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get human-readable description for error code
|
|
165
|
+
*/
|
|
166
|
+
getErrorDescription(code) {
|
|
167
|
+
return ERROR_CODES[code] || 'Unknown error';
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Get all error handlers (for testing)
|
|
171
|
+
*/
|
|
172
|
+
getHandlers() {
|
|
173
|
+
return [...this.handlers];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Get recent errors for a specific phase
|
|
177
|
+
*/
|
|
178
|
+
getRecentErrorsForPhase(phase, limit = 10) {
|
|
179
|
+
return this.errors
|
|
180
|
+
.filter((error) => error.context.phase === phase)
|
|
181
|
+
.slice(-limit);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get error statistics
|
|
185
|
+
*/
|
|
186
|
+
getStats() {
|
|
187
|
+
const byPhase = {
|
|
188
|
+
cleanup: 0,
|
|
189
|
+
discovery: 0,
|
|
190
|
+
execution: 0,
|
|
191
|
+
loading: 0,
|
|
192
|
+
reporting: 0,
|
|
193
|
+
setup: 0,
|
|
194
|
+
teardown: 0,
|
|
195
|
+
validation: 0,
|
|
196
|
+
};
|
|
197
|
+
const byType = {};
|
|
198
|
+
let firstError;
|
|
199
|
+
let lastError;
|
|
200
|
+
for (const error of this.errors) {
|
|
201
|
+
// Count by phase
|
|
202
|
+
byPhase[error.context.phase]++;
|
|
203
|
+
// Count by type (error code)
|
|
204
|
+
const type = error.code;
|
|
205
|
+
byType[type] = (byType[type] || 0) + 1;
|
|
206
|
+
// Track timestamps
|
|
207
|
+
const timestamp = error.processedAt;
|
|
208
|
+
if (!firstError || timestamp < firstError) {
|
|
209
|
+
firstError = timestamp;
|
|
210
|
+
}
|
|
211
|
+
if (!lastError || timestamp > lastError) {
|
|
212
|
+
lastError = timestamp;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const result = {
|
|
216
|
+
byPhase,
|
|
217
|
+
byType,
|
|
218
|
+
...(firstError && { firstError }),
|
|
219
|
+
...(lastError && { lastError }),
|
|
220
|
+
recent: this.errors.slice(-this.maxRecentErrors),
|
|
221
|
+
total: this.errors.length,
|
|
222
|
+
};
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Handle an execution error
|
|
227
|
+
*/
|
|
228
|
+
handleError(error, context) {
|
|
229
|
+
const code = this.getErrorCode(error, context);
|
|
230
|
+
const recoverable = this.isRecoverableByCode(code);
|
|
231
|
+
const executionError = {
|
|
232
|
+
code,
|
|
233
|
+
context,
|
|
234
|
+
message: this.createMessage(error, context, code),
|
|
235
|
+
originalError: error,
|
|
236
|
+
processedAt: new Date(),
|
|
237
|
+
recoverable,
|
|
238
|
+
...(error.stack && { stack: error.stack }),
|
|
239
|
+
};
|
|
240
|
+
// Store error for statistics
|
|
241
|
+
this.errors.push(executionError);
|
|
242
|
+
// Keep only recent errors to prevent memory leaks
|
|
243
|
+
if (this.errors.length > this.maxRecentErrors * 2) {
|
|
244
|
+
this.errors = this.errors.slice(-this.maxRecentErrors);
|
|
245
|
+
}
|
|
246
|
+
// Notify handlers
|
|
247
|
+
for (const handler of this.handlers) {
|
|
248
|
+
try {
|
|
249
|
+
handler(executionError);
|
|
250
|
+
}
|
|
251
|
+
catch (handlerError) {
|
|
252
|
+
// Don't let handler errors break error handling
|
|
253
|
+
console.error('Error in error handler:', handlerError);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return executionError;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Check if an error is recoverable
|
|
260
|
+
*/
|
|
261
|
+
isRecoverable(error) {
|
|
262
|
+
return error.recoverable;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Register error handler callback
|
|
266
|
+
*/
|
|
267
|
+
onError(handler) {
|
|
268
|
+
this.handlers.push(handler);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Remove error handler
|
|
272
|
+
*/
|
|
273
|
+
removeHandler(handler) {
|
|
274
|
+
const index = this.handlers.indexOf(handler);
|
|
275
|
+
if (index >= 0) {
|
|
276
|
+
this.handlers.splice(index, 1);
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Create human-readable error message
|
|
283
|
+
*/
|
|
284
|
+
createMessage(error, context, code) {
|
|
285
|
+
const baseMessage = this.getErrorDescription(code);
|
|
286
|
+
const originalMessage = error.message;
|
|
287
|
+
// If the original message is more descriptive, use it
|
|
288
|
+
if (originalMessage &&
|
|
289
|
+
originalMessage !== baseMessage &&
|
|
290
|
+
!originalMessage.includes('[object')) {
|
|
291
|
+
return `${baseMessage}: ${originalMessage}`;
|
|
292
|
+
}
|
|
293
|
+
return baseMessage;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Check if error is recoverable by code
|
|
297
|
+
*/
|
|
298
|
+
isRecoverableByCode(code) {
|
|
299
|
+
return RECOVERABLE_ERRORS.has(code);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
exports.ModestBenchErrorManager = ModestBenchErrorManager;
|
|
303
|
+
//# sourceMappingURL=error-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-manager.js","sourceRoot":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C;IAED;;OAEG;IACH,aAAa,CAAC,KAAqB;QACjC,OAAO,KAAK,CAAC,WAAW,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,OAAqB;QAC3B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,OAAqB;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACK,aAAa,CACnB,KAAY,EACZ,OAAqB,EACrB,IAAY;QAEZ,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACnD,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CAAC;QAEtC,sDAAsD;QACtD,IACE,eAAe;YACf,eAAe,KAAK,WAAW;YAC/B,CAAC,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,EACpC,CAAC;YACD,OAAO,GAAG,WAAW,KAAK,eAAe,EAAE,CAAC;QAC9C,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;OAEG;IACK,mBAAmB,CAAC,IAAY;QACtC,OAAO,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF;AApSD,0DAoSC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModestBench Error Manager
|
|
3
|
+
*
|
|
4
|
+
* Handles execution errors with context tracking, categorization, and provides
|
|
5
|
+
* structured error information for graceful degradation.
|
|
6
|
+
*/
|
|
7
|
+
import type { ErrorContext, ErrorManager, ErrorStats, ExecutionError, ExecutionPhase } from "../types/index.cjs";
|
|
8
|
+
/**
|
|
9
|
+
* Error handler callback type
|
|
10
|
+
*/
|
|
11
|
+
type ErrorHandler = (error: ExecutionError) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Default error manager implementation
|
|
14
|
+
*/
|
|
15
|
+
export declare class ModestBenchErrorManager implements ErrorManager {
|
|
16
|
+
private errors;
|
|
17
|
+
private handlers;
|
|
18
|
+
private readonly maxRecentErrors;
|
|
19
|
+
/**
|
|
20
|
+
* Clear error history
|
|
21
|
+
*/
|
|
22
|
+
clearStats(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Format error for display
|
|
25
|
+
*/
|
|
26
|
+
formatError(error: ExecutionError): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get error code for a given error
|
|
29
|
+
*/
|
|
30
|
+
getErrorCode(error: Error, context: ErrorContext): string;
|
|
31
|
+
/**
|
|
32
|
+
* Get error count by phase
|
|
33
|
+
*/
|
|
34
|
+
getErrorCountByPhase(phase: ExecutionPhase): number;
|
|
35
|
+
/**
|
|
36
|
+
* Get human-readable description for error code
|
|
37
|
+
*/
|
|
38
|
+
getErrorDescription(code: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Get all error handlers (for testing)
|
|
41
|
+
*/
|
|
42
|
+
getHandlers(): readonly ErrorHandler[];
|
|
43
|
+
/**
|
|
44
|
+
* Get recent errors for a specific phase
|
|
45
|
+
*/
|
|
46
|
+
getRecentErrorsForPhase(phase: ExecutionPhase, limit?: number): ExecutionError[];
|
|
47
|
+
/**
|
|
48
|
+
* Get error statistics
|
|
49
|
+
*/
|
|
50
|
+
getStats(): ErrorStats;
|
|
51
|
+
/**
|
|
52
|
+
* Handle an execution error
|
|
53
|
+
*/
|
|
54
|
+
handleError(error: Error, context: ErrorContext): ExecutionError;
|
|
55
|
+
/**
|
|
56
|
+
* Check if an error is recoverable
|
|
57
|
+
*/
|
|
58
|
+
isRecoverable(error: ExecutionError): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Register error handler callback
|
|
61
|
+
*/
|
|
62
|
+
onError(handler: ErrorHandler): void;
|
|
63
|
+
/**
|
|
64
|
+
* Remove error handler
|
|
65
|
+
*/
|
|
66
|
+
removeHandler(handler: ErrorHandler): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Create human-readable error message
|
|
69
|
+
*/
|
|
70
|
+
private createMessage;
|
|
71
|
+
/**
|
|
72
|
+
* Check if error is recoverable by code
|
|
73
|
+
*/
|
|
74
|
+
private isRecoverableByCode;
|
|
75
|
+
}
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=error-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-manager.d.ts","sourceRoot":"","sources":["../../src/core/error-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,cAAc,EACd,cAAc,EACf,2BAA0B;AAE3B;;GAEG;AACH,KAAK,YAAY,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;AA0DpD;;GAEG;AACH,qBAAa,uBAAwB,YAAW,YAAY;IAC1D,OAAO,CAAC,MAAM,CAAwB;IAEtC,OAAO,CAAC,QAAQ,CAAsB;IAEtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAM;IAEtC;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM;IA0B1C;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM;IA0EzD;;OAEG;IACH,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM;IAInD;;OAEG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIzC;;OAEG;IACH,WAAW,IAAI,SAAS,YAAY,EAAE;IAItC;;OAEG;IACH,uBAAuB,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,SAAK,GAAG,cAAc,EAAE;IAM5E;;OAEG;IACH,QAAQ,IAAI,UAAU;IA8CtB;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,GAAG,cAAc;IAmChE;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO;IAI7C;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAIpC;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO;IAS7C;;OAEG;IACH,OAAO,CAAC,aAAa;IAoBrB;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAG5B"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModestBench Error Manager
|
|
3
|
+
*
|
|
4
|
+
* Handles execution errors with context tracking, categorization, and provides
|
|
5
|
+
* structured error information for graceful degradation.
|
|
6
|
+
*/
|
|
7
|
+
import type { ErrorContext, ErrorManager, ErrorStats, ExecutionError, ExecutionPhase } from "../types/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* Error handler callback type
|
|
10
|
+
*/
|
|
11
|
+
type ErrorHandler = (error: ExecutionError) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Default error manager implementation
|
|
14
|
+
*/
|
|
15
|
+
export declare class ModestBenchErrorManager implements ErrorManager {
|
|
16
|
+
private errors;
|
|
17
|
+
private handlers;
|
|
18
|
+
private readonly maxRecentErrors;
|
|
19
|
+
/**
|
|
20
|
+
* Clear error history
|
|
21
|
+
*/
|
|
22
|
+
clearStats(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Format error for display
|
|
25
|
+
*/
|
|
26
|
+
formatError(error: ExecutionError): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get error code for a given error
|
|
29
|
+
*/
|
|
30
|
+
getErrorCode(error: Error, context: ErrorContext): string;
|
|
31
|
+
/**
|
|
32
|
+
* Get error count by phase
|
|
33
|
+
*/
|
|
34
|
+
getErrorCountByPhase(phase: ExecutionPhase): number;
|
|
35
|
+
/**
|
|
36
|
+
* Get human-readable description for error code
|
|
37
|
+
*/
|
|
38
|
+
getErrorDescription(code: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Get all error handlers (for testing)
|
|
41
|
+
*/
|
|
42
|
+
getHandlers(): readonly ErrorHandler[];
|
|
43
|
+
/**
|
|
44
|
+
* Get recent errors for a specific phase
|
|
45
|
+
*/
|
|
46
|
+
getRecentErrorsForPhase(phase: ExecutionPhase, limit?: number): ExecutionError[];
|
|
47
|
+
/**
|
|
48
|
+
* Get error statistics
|
|
49
|
+
*/
|
|
50
|
+
getStats(): ErrorStats;
|
|
51
|
+
/**
|
|
52
|
+
* Handle an execution error
|
|
53
|
+
*/
|
|
54
|
+
handleError(error: Error, context: ErrorContext): ExecutionError;
|
|
55
|
+
/**
|
|
56
|
+
* Check if an error is recoverable
|
|
57
|
+
*/
|
|
58
|
+
isRecoverable(error: ExecutionError): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Register error handler callback
|
|
61
|
+
*/
|
|
62
|
+
onError(handler: ErrorHandler): void;
|
|
63
|
+
/**
|
|
64
|
+
* Remove error handler
|
|
65
|
+
*/
|
|
66
|
+
removeHandler(handler: ErrorHandler): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Create human-readable error message
|
|
69
|
+
*/
|
|
70
|
+
private createMessage;
|
|
71
|
+
/**
|
|
72
|
+
* Check if error is recoverable by code
|
|
73
|
+
*/
|
|
74
|
+
private isRecoverableByCode;
|
|
75
|
+
}
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=error-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-manager.d.ts","sourceRoot":"","sources":["../../src/core/error-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,UA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