modestbench 0.0.3 → 0.1.0
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 +15 -0
- package/dist/bootstrap.cjs +0 -2
- package/dist/bootstrap.cjs.map +1 -1
- package/dist/bootstrap.d.cts.map +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +0 -2
- package/dist/bootstrap.js.map +1 -1
- package/dist/cli/commands/history.cjs +2 -1
- package/dist/cli/commands/history.cjs.map +1 -1
- package/dist/cli/commands/history.d.cts.map +1 -1
- package/dist/cli/commands/history.d.ts.map +1 -1
- package/dist/cli/commands/history.js +2 -1
- package/dist/cli/commands/history.js.map +1 -1
- package/dist/cli/commands/init.cjs +5 -4
- package/dist/cli/commands/init.cjs.map +1 -1
- package/dist/cli/commands/init.d.cts.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +5 -4
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/run.cjs +14 -4
- package/dist/cli/commands/run.cjs.map +1 -1
- package/dist/cli/commands/run.d.cts.map +1 -1
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +14 -4
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/index.cjs +29 -12
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +1 -2
- package/dist/cli/index.d.cts.map +1 -1
- package/dist/cli/index.d.ts +1 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +24 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/config/manager.cjs +8 -2
- package/dist/config/manager.cjs.map +1 -1
- package/dist/config/manager.d.cts.map +1 -1
- package/dist/config/manager.d.ts.map +1 -1
- package/dist/config/manager.js +8 -2
- package/dist/config/manager.js.map +1 -1
- package/dist/constants.cjs +53 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +36 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.ts +36 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +52 -0
- package/dist/constants.js.map +1 -1
- package/dist/core/engine.cjs +15 -42
- package/dist/core/engine.cjs.map +1 -1
- package/dist/core/engine.d.cts +1 -3
- package/dist/core/engine.d.cts.map +1 -1
- package/dist/core/engine.d.ts +1 -3
- package/dist/core/engine.d.ts.map +1 -1
- package/dist/core/engine.js +15 -42
- package/dist/core/engine.js.map +1 -1
- package/dist/core/engines/accurate-engine.cjs +2 -1
- package/dist/core/engines/accurate-engine.cjs.map +1 -1
- package/dist/core/engines/accurate-engine.d.cts.map +1 -1
- package/dist/core/engines/accurate-engine.d.ts.map +1 -1
- package/dist/core/engines/accurate-engine.js +2 -1
- package/dist/core/engines/accurate-engine.js.map +1 -1
- package/dist/core/engines/tinybench-engine.cjs +6 -5
- package/dist/core/engines/tinybench-engine.cjs.map +1 -1
- package/dist/core/engines/tinybench-engine.d.cts.map +1 -1
- package/dist/core/engines/tinybench-engine.d.ts.map +1 -1
- package/dist/core/engines/tinybench-engine.js +6 -5
- package/dist/core/engines/tinybench-engine.js.map +1 -1
- package/dist/core/loader.cjs +16 -5
- package/dist/core/loader.cjs.map +1 -1
- package/dist/core/loader.d.cts.map +1 -1
- package/dist/core/loader.d.ts.map +1 -1
- package/dist/core/loader.js +16 -5
- package/dist/core/loader.js.map +1 -1
- package/dist/errors/base.cjs +130 -0
- package/dist/errors/base.cjs.map +1 -0
- package/dist/errors/base.d.cts +97 -0
- package/dist/errors/base.d.cts.map +1 -0
- package/dist/errors/base.d.ts +97 -0
- package/dist/errors/base.d.ts.map +1 -0
- package/dist/errors/base.js +124 -0
- package/dist/errors/base.js.map +1 -0
- package/dist/errors/cli.cjs +58 -0
- package/dist/errors/cli.cjs.map +1 -0
- package/dist/errors/cli.d.cts +44 -0
- package/dist/errors/cli.d.cts.map +1 -0
- package/dist/errors/cli.d.ts +44 -0
- package/dist/errors/cli.d.ts.map +1 -0
- package/dist/errors/cli.js +52 -0
- package/dist/errors/cli.js.map +1 -0
- package/dist/errors/configuration.cjs +48 -0
- package/dist/errors/configuration.cjs.map +1 -0
- package/dist/errors/configuration.d.cts +41 -0
- package/dist/errors/configuration.d.cts.map +1 -0
- package/dist/errors/configuration.d.ts +41 -0
- package/dist/errors/configuration.d.ts.map +1 -0
- package/dist/errors/configuration.js +41 -0
- package/dist/errors/configuration.js.map +1 -0
- package/dist/errors/execution.cjs +65 -0
- package/dist/errors/execution.cjs.map +1 -0
- package/dist/errors/execution.d.cts +56 -0
- package/dist/errors/execution.d.cts.map +1 -0
- package/dist/errors/execution.d.ts +56 -0
- package/dist/errors/execution.d.ts.map +1 -0
- package/dist/errors/execution.js +56 -0
- package/dist/errors/execution.js.map +1 -0
- package/dist/errors/file.cjs +56 -0
- package/dist/errors/file.cjs.map +1 -0
- package/dist/errors/file.d.cts +48 -0
- package/dist/errors/file.d.cts.map +1 -0
- package/dist/errors/file.d.ts +48 -0
- package/dist/errors/file.d.ts.map +1 -0
- package/dist/errors/file.js +48 -0
- package/dist/errors/file.js.map +1 -0
- package/dist/errors/index.cjs +59 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.cts +16 -0
- package/dist/errors/index.d.cts.map +1 -0
- package/dist/errors/index.d.ts +16 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +24 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/reporter.cjs +38 -0
- package/dist/errors/reporter.cjs.map +1 -0
- package/dist/errors/reporter.d.cts +32 -0
- package/dist/errors/reporter.d.cts.map +1 -0
- package/dist/errors/reporter.d.ts +32 -0
- package/dist/errors/reporter.d.ts.map +1 -0
- package/dist/errors/reporter.js +32 -0
- package/dist/errors/reporter.js.map +1 -0
- package/dist/errors/storage.cjs +55 -0
- package/dist/errors/storage.cjs.map +1 -0
- package/dist/errors/storage.d.cts +47 -0
- package/dist/errors/storage.d.cts.map +1 -0
- package/dist/errors/storage.d.ts +47 -0
- package/dist/errors/storage.d.ts.map +1 -0
- package/dist/errors/storage.js +47 -0
- package/dist/errors/storage.js.map +1 -0
- package/dist/errors/validation.cjs +38 -0
- package/dist/errors/validation.cjs.map +1 -0
- package/dist/errors/validation.d.cts +32 -0
- package/dist/errors/validation.d.cts.map +1 -0
- package/dist/errors/validation.d.ts +32 -0
- package/dist/errors/validation.d.ts.map +1 -0
- package/dist/errors/validation.js +32 -0
- package/dist/errors/validation.js.map +1 -0
- package/dist/index.cjs +3 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/reporters/csv.cjs +3 -2
- package/dist/reporters/csv.cjs.map +1 -1
- package/dist/reporters/csv.d.cts.map +1 -1
- package/dist/reporters/csv.d.ts.map +1 -1
- package/dist/reporters/csv.js +3 -2
- package/dist/reporters/csv.js.map +1 -1
- package/dist/reporters/human.cjs +1 -1
- package/dist/reporters/human.js +1 -1
- package/dist/reporters/json.cjs +3 -2
- package/dist/reporters/json.cjs.map +1 -1
- package/dist/reporters/json.d.cts.map +1 -1
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +3 -2
- package/dist/reporters/json.js.map +1 -1
- package/dist/reporters/registry.cjs +3 -2
- package/dist/reporters/registry.cjs.map +1 -1
- package/dist/reporters/registry.d.cts.map +1 -1
- package/dist/reporters/registry.d.ts.map +1 -1
- package/dist/reporters/registry.js +3 -2
- package/dist/reporters/registry.js.map +1 -1
- package/dist/reporters/simple.cjs +1 -1
- package/dist/reporters/simple.js +1 -1
- package/dist/storage/history.cjs +32 -11
- package/dist/storage/history.cjs.map +1 -1
- package/dist/storage/history.d.cts.map +1 -1
- package/dist/storage/history.d.ts.map +1 -1
- package/dist/storage/history.js +32 -11
- package/dist/storage/history.js.map +1 -1
- package/dist/types/interfaces.d.cts +1 -34
- package/dist/types/interfaces.d.cts.map +1 -1
- package/dist/types/interfaces.d.ts +1 -34
- package/dist/types/interfaces.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/bootstrap.ts +0 -2
- package/src/cli/commands/history.ts +3 -1
- package/src/cli/commands/init.ts +14 -4
- package/src/cli/commands/run.ts +20 -4
- package/src/cli/index.ts +32 -13
- package/src/config/manager.ts +12 -2
- package/src/constants.ts +60 -0
- package/src/core/engine.ts +31 -47
- package/src/core/engines/accurate-engine.ts +4 -1
- package/src/core/engines/tinybench-engine.ts +12 -5
- package/src/core/loader.ts +27 -5
- package/src/errors/base.ts +152 -0
- package/src/errors/cli.ts +59 -0
- package/src/errors/configuration.ts +45 -0
- package/src/errors/execution.ts +62 -0
- package/src/errors/file.ts +53 -0
- package/src/errors/index.ts +71 -0
- package/src/errors/reporter.ts +35 -0
- package/src/errors/storage.ts +52 -0
- package/src/errors/validation.ts +35 -0
- package/src/index.ts +3 -3
- package/src/reporters/csv.ts +4 -2
- package/src/reporters/human.ts +1 -1
- package/src/reporters/json.ts +4 -2
- package/src/reporters/registry.ts +9 -2
- package/src/reporters/simple.ts +1 -1
- package/src/storage/history.ts +58 -11
- package/src/types/interfaces.ts +0 -43
- package/dist/core/error-manager.cjs +0 -303
- package/dist/core/error-manager.cjs.map +0 -1
- package/dist/core/error-manager.d.cts +0 -77
- package/dist/core/error-manager.d.cts.map +0 -1
- package/dist/core/error-manager.d.ts +0 -77
- package/dist/core/error-manager.d.ts.map +0 -1
- package/dist/core/error-manager.js +0 -299
- package/dist/core/error-manager.js.map +0 -1
- package/src/core/error-manager.ts +0 -372
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration-related errors
|
|
3
|
+
*
|
|
4
|
+
* Errors that occur during configuration file loading, parsing, and validation.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ModestBenchError } from './base.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Failed to load configuration
|
|
11
|
+
*
|
|
12
|
+
* Thrown when configuration loading fails for reasons other than file not found
|
|
13
|
+
* (e.g., parse errors, module loading errors).
|
|
14
|
+
*/
|
|
15
|
+
export class ConfigLoadError extends ModestBenchError {
|
|
16
|
+
readonly code = 'ERR_MB_CONFIG_LOAD_FAILED';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Configuration file not found
|
|
21
|
+
*
|
|
22
|
+
* Thrown when a specified configuration file cannot be found.
|
|
23
|
+
*/
|
|
24
|
+
export class ConfigNotFoundError extends ModestBenchError {
|
|
25
|
+
readonly code = 'ERR_MB_CONFIG_NOT_FOUND';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Configuration validation failed
|
|
30
|
+
*
|
|
31
|
+
* Thrown when a configuration file or configuration options fail schema
|
|
32
|
+
* validation.
|
|
33
|
+
*/
|
|
34
|
+
export class ConfigValidationError extends ModestBenchError {
|
|
35
|
+
readonly code = 'ERR_MB_CONFIG_VALIDATION_FAILED';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Unsupported configuration format
|
|
40
|
+
*
|
|
41
|
+
* Thrown when attempting to use an unsupported configuration file format.
|
|
42
|
+
*/
|
|
43
|
+
export class UnsupportedConfigFormatError extends ModestBenchError {
|
|
44
|
+
readonly code = 'ERR_MB_CONFIG_UNSUPPORTED_FORMAT';
|
|
45
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution-related errors
|
|
3
|
+
*
|
|
4
|
+
* Errors that occur during benchmark execution, setup, and teardown.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ModestBenchError } from './base.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Benchmark execution failed
|
|
11
|
+
*
|
|
12
|
+
* Thrown when overall benchmark execution fails.
|
|
13
|
+
*/
|
|
14
|
+
export class BenchmarkExecutionError extends ModestBenchError {
|
|
15
|
+
readonly code = 'ERR_MB_EXECUTION_BENCHMARK_FAILED';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Operation too fast to measure
|
|
20
|
+
*
|
|
21
|
+
* Thrown when a benchmark operation executes so quickly that it cannot be
|
|
22
|
+
* reliably measured (typically < 1ns per operation).
|
|
23
|
+
*/
|
|
24
|
+
export class OperationTooFastError extends ModestBenchError {
|
|
25
|
+
readonly code = 'ERR_MB_EXECUTION_TOO_FAST';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Setup function failed
|
|
30
|
+
*
|
|
31
|
+
* Thrown when a benchmark setup function fails.
|
|
32
|
+
*/
|
|
33
|
+
export class SetupError extends ModestBenchError {
|
|
34
|
+
readonly code = 'ERR_MB_EXECUTION_SETUP_FAILED';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Task execution failed
|
|
39
|
+
*
|
|
40
|
+
* Thrown when a specific benchmark task fails during execution.
|
|
41
|
+
*/
|
|
42
|
+
export class TaskExecutionError extends ModestBenchError {
|
|
43
|
+
readonly code = 'ERR_MB_EXECUTION_TASK_FAILED';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Teardown function failed
|
|
48
|
+
*
|
|
49
|
+
* Thrown when a benchmark teardown function fails.
|
|
50
|
+
*/
|
|
51
|
+
export class TeardownError extends ModestBenchError {
|
|
52
|
+
readonly code = 'ERR_MB_EXECUTION_TEARDOWN_FAILED';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Execution timeout exceeded
|
|
57
|
+
*
|
|
58
|
+
* Thrown when a benchmark operation exceeds the configured timeout.
|
|
59
|
+
*/
|
|
60
|
+
export class TimeoutError extends ModestBenchError {
|
|
61
|
+
readonly code = 'ERR_MB_EXECUTION_TIMEOUT';
|
|
62
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-related errors
|
|
3
|
+
*
|
|
4
|
+
* Errors that occur during file discovery, loading, and access.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ModestBenchError } from './base.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* File discovery failed
|
|
11
|
+
*
|
|
12
|
+
* Thrown when file discovery/glob pattern matching fails.
|
|
13
|
+
*/
|
|
14
|
+
export class FileDiscoveryError extends ModestBenchError {
|
|
15
|
+
readonly code = 'ERR_MB_FILE_DISCOVERY_FAILED';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Failed to load benchmark file
|
|
20
|
+
*
|
|
21
|
+
* Thrown when loading a benchmark file fails (e.g., import errors, syntax
|
|
22
|
+
* errors).
|
|
23
|
+
*/
|
|
24
|
+
export class FileLoadError extends ModestBenchError {
|
|
25
|
+
readonly code = 'ERR_MB_FILE_LOAD_FAILED';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Benchmark file not found
|
|
30
|
+
*
|
|
31
|
+
* Thrown when a benchmark file cannot be found or does not exist.
|
|
32
|
+
*/
|
|
33
|
+
export class FileNotFoundError extends ModestBenchError {
|
|
34
|
+
readonly code = 'ERR_MB_FILE_NOT_FOUND';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* File permission denied
|
|
39
|
+
*
|
|
40
|
+
* Thrown when file access is denied due to insufficient permissions.
|
|
41
|
+
*/
|
|
42
|
+
export class FilePermissionError extends ModestBenchError {
|
|
43
|
+
readonly code = 'ERR_MB_FILE_PERMISSION_DENIED';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Unsupported file extension
|
|
48
|
+
*
|
|
49
|
+
* Thrown when attempting to load a file with an unsupported extension.
|
|
50
|
+
*/
|
|
51
|
+
export class UnsupportedFileExtensionError extends ModestBenchError {
|
|
52
|
+
readonly code = 'ERR_MB_FILE_UNSUPPORTED_EXTENSION';
|
|
53
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModestBench Error Classes
|
|
3
|
+
*
|
|
4
|
+
* Custom error classes for structured error handling throughout ModestBench.
|
|
5
|
+
* All errors extend ModestBenchError and include error codes and documentation
|
|
6
|
+
* URLs.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Base error classes and utilities
|
|
10
|
+
export {
|
|
11
|
+
isModestBenchError,
|
|
12
|
+
ModestBenchAggregateError,
|
|
13
|
+
ModestBenchError,
|
|
14
|
+
} from './base.js';
|
|
15
|
+
|
|
16
|
+
// CLI errors
|
|
17
|
+
export {
|
|
18
|
+
InvalidArgumentError,
|
|
19
|
+
InvalidDateFormatError,
|
|
20
|
+
UnknownError,
|
|
21
|
+
} from './cli.js';
|
|
22
|
+
|
|
23
|
+
// Configuration errors
|
|
24
|
+
export {
|
|
25
|
+
ConfigLoadError,
|
|
26
|
+
ConfigNotFoundError,
|
|
27
|
+
ConfigValidationError,
|
|
28
|
+
UnsupportedConfigFormatError,
|
|
29
|
+
} from './configuration.js';
|
|
30
|
+
|
|
31
|
+
// Execution errors
|
|
32
|
+
export {
|
|
33
|
+
BenchmarkExecutionError,
|
|
34
|
+
OperationTooFastError,
|
|
35
|
+
SetupError,
|
|
36
|
+
TaskExecutionError,
|
|
37
|
+
TeardownError,
|
|
38
|
+
TimeoutError,
|
|
39
|
+
} from './execution.js';
|
|
40
|
+
|
|
41
|
+
// File errors
|
|
42
|
+
export {
|
|
43
|
+
FileDiscoveryError,
|
|
44
|
+
FileLoadError,
|
|
45
|
+
FileNotFoundError,
|
|
46
|
+
FilePermissionError,
|
|
47
|
+
UnsupportedFileExtensionError,
|
|
48
|
+
} from './file.js';
|
|
49
|
+
|
|
50
|
+
// Reporter errors
|
|
51
|
+
export {
|
|
52
|
+
ReporterAlreadyRegisteredError,
|
|
53
|
+
ReporterOutputError,
|
|
54
|
+
UnknownReporterError,
|
|
55
|
+
} from './reporter.js';
|
|
56
|
+
|
|
57
|
+
// Storage errors
|
|
58
|
+
export {
|
|
59
|
+
StorageCorruptionError,
|
|
60
|
+
StorageError,
|
|
61
|
+
StorageIndexError,
|
|
62
|
+
StorageSpaceError,
|
|
63
|
+
UnsupportedExportFormatError,
|
|
64
|
+
} from './storage.js';
|
|
65
|
+
|
|
66
|
+
// Validation errors
|
|
67
|
+
export {
|
|
68
|
+
SchemaValidationError,
|
|
69
|
+
StructureValidationError,
|
|
70
|
+
TypeValidationError,
|
|
71
|
+
} from './validation.js';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reporter-related errors
|
|
3
|
+
*
|
|
4
|
+
* Errors that occur during reporter operations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ModestBenchError } from './base.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Reporter already registered
|
|
11
|
+
*
|
|
12
|
+
* Thrown when attempting to register a reporter with a name that is already in
|
|
13
|
+
* use.
|
|
14
|
+
*/
|
|
15
|
+
export class ReporterAlreadyRegisteredError extends ModestBenchError {
|
|
16
|
+
readonly code = 'ERR_MB_REPORTER_ALREADY_REGISTERED';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Reporter output failed
|
|
21
|
+
*
|
|
22
|
+
* Thrown when a reporter fails to write output.
|
|
23
|
+
*/
|
|
24
|
+
export class ReporterOutputError extends ModestBenchError {
|
|
25
|
+
readonly code = 'ERR_MB_REPORTER_OUTPUT_FAILED';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Unknown reporter
|
|
30
|
+
*
|
|
31
|
+
* Thrown when attempting to use a reporter that is not registered.
|
|
32
|
+
*/
|
|
33
|
+
export class UnknownReporterError extends ModestBenchError {
|
|
34
|
+
readonly code = 'ERR_MB_REPORTER_UNKNOWN';
|
|
35
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage-related errors
|
|
3
|
+
*
|
|
4
|
+
* Errors that occur during history storage operations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ModestBenchError } from './base.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Storage data corruption
|
|
11
|
+
*
|
|
12
|
+
* Thrown when stored data is found to be corrupted or invalid.
|
|
13
|
+
*/
|
|
14
|
+
export class StorageCorruptionError extends ModestBenchError {
|
|
15
|
+
readonly code = 'ERR_MB_STORAGE_CORRUPTION';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Storage operation failed
|
|
20
|
+
*
|
|
21
|
+
* Thrown when a general storage operation fails.
|
|
22
|
+
*/
|
|
23
|
+
export class StorageError extends ModestBenchError {
|
|
24
|
+
readonly code = 'ERR_MB_STORAGE_FAILED';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Storage index corruption
|
|
29
|
+
*
|
|
30
|
+
* Thrown when the storage index is corrupted or cannot be read.
|
|
31
|
+
*/
|
|
32
|
+
export class StorageIndexError extends ModestBenchError {
|
|
33
|
+
readonly code = 'ERR_MB_STORAGE_INDEX_CORRUPTION';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Insufficient storage space
|
|
38
|
+
*
|
|
39
|
+
* Thrown when there is insufficient disk space for storage operations.
|
|
40
|
+
*/
|
|
41
|
+
export class StorageSpaceError extends ModestBenchError {
|
|
42
|
+
readonly code = 'ERR_MB_STORAGE_INSUFFICIENT_SPACE';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Unsupported export format
|
|
47
|
+
*
|
|
48
|
+
* Thrown when attempting to export data in an unsupported format.
|
|
49
|
+
*/
|
|
50
|
+
export class UnsupportedExportFormatError extends ModestBenchError {
|
|
51
|
+
readonly code = 'ERR_MB_STORAGE_EXPORT_UNSUPPORTED';
|
|
52
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation-related errors
|
|
3
|
+
*
|
|
4
|
+
* Errors that occur during benchmark file structure and data validation.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ModestBenchError } from './base.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Schema validation failed
|
|
11
|
+
*
|
|
12
|
+
* Thrown when data fails to validate against a Zod schema or other schema
|
|
13
|
+
* validation.
|
|
14
|
+
*/
|
|
15
|
+
export class SchemaValidationError extends ModestBenchError {
|
|
16
|
+
readonly code = 'ERR_MB_VALIDATION_SCHEMA_FAILED';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Invalid benchmark structure
|
|
21
|
+
*
|
|
22
|
+
* Thrown when a benchmark file has an invalid or unexpected structure.
|
|
23
|
+
*/
|
|
24
|
+
export class StructureValidationError extends ModestBenchError {
|
|
25
|
+
readonly code = 'ERR_MB_VALIDATION_STRUCTURE_INVALID';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Type validation failed
|
|
30
|
+
*
|
|
31
|
+
* Thrown when data fails type validation checks.
|
|
32
|
+
*/
|
|
33
|
+
export class TypeValidationError extends ModestBenchError {
|
|
34
|
+
readonly code = 'ERR_MB_VALIDATION_TYPE_FAILED';
|
|
35
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -14,9 +14,6 @@ export { ModestBenchConfigurationManager } from './config/manager.js';
|
|
|
14
14
|
export { ModestBenchEngine } from './core/engine.js';
|
|
15
15
|
export { AccurateEngine, TinybenchEngine } from './core/engines/index.js';
|
|
16
16
|
|
|
17
|
-
// Error handling
|
|
18
|
-
export { ModestBenchErrorManager } from './core/error-manager.js';
|
|
19
|
-
|
|
20
17
|
export { BenchmarkFileLoader } from './core/loader.js';
|
|
21
18
|
|
|
22
19
|
// Statistical utilities
|
|
@@ -26,6 +23,9 @@ export {
|
|
|
26
23
|
type SampleStatistics,
|
|
27
24
|
} from './core/stats-utils.js';
|
|
28
25
|
|
|
26
|
+
// Error classes
|
|
27
|
+
export * from './errors/index.js';
|
|
28
|
+
|
|
29
29
|
// Progress tracking
|
|
30
30
|
export { ModestBenchProgressManager } from './progress/manager.js';
|
|
31
31
|
// Reporters
|
package/src/reporters/csv.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
TaskResult,
|
|
18
18
|
} from '../types/index.js';
|
|
19
19
|
|
|
20
|
+
import { ReporterOutputError } from '../errors/index.js';
|
|
20
21
|
import { BaseReporter } from './registry.js';
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -340,7 +341,7 @@ export class CsvReporter extends BaseReporter {
|
|
|
340
341
|
*/
|
|
341
342
|
private async writeToFile(csvContent: string): Promise<void> {
|
|
342
343
|
if (!this.outputPath) {
|
|
343
|
-
throw new
|
|
344
|
+
throw new ReporterOutputError('Output path not specified');
|
|
344
345
|
}
|
|
345
346
|
|
|
346
347
|
try {
|
|
@@ -351,8 +352,9 @@ export class CsvReporter extends BaseReporter {
|
|
|
351
352
|
// Write CSV file
|
|
352
353
|
writeFileSync(this.outputPath, csvContent, 'utf8');
|
|
353
354
|
} catch (error) {
|
|
354
|
-
throw new
|
|
355
|
+
throw new ReporterOutputError(
|
|
355
356
|
`Failed to write CSV output to ${this.outputPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
357
|
+
{ cause: error },
|
|
356
358
|
);
|
|
357
359
|
}
|
|
358
360
|
}
|
package/src/reporters/human.ts
CHANGED
|
@@ -157,7 +157,7 @@ export class HumanReporter extends BaseReporter {
|
|
|
157
157
|
);
|
|
158
158
|
} else {
|
|
159
159
|
this.printLine(
|
|
160
|
-
`${this.colorize('brightCyan', ansiChars.checkmark + ' All
|
|
160
|
+
`${this.colorize('brightCyan', ansiChars.checkmark + ' All tasks passed:')} ${this.colorize('brightWhite', String(totalPassed))}`,
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
163
|
this.printLine(
|
package/src/reporters/json.ts
CHANGED
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
TaskResult,
|
|
17
17
|
} from '../types/index.js';
|
|
18
18
|
|
|
19
|
+
import { ReporterOutputError } from '../errors/index.js';
|
|
19
20
|
import { BaseReporter } from './registry.js';
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -266,7 +267,7 @@ export class JsonReporter extends BaseReporter {
|
|
|
266
267
|
*/
|
|
267
268
|
private async writeToFile(output: JsonOutput): Promise<void> {
|
|
268
269
|
if (!this.outputPath) {
|
|
269
|
-
throw new
|
|
270
|
+
throw new ReporterOutputError('Output path not specified');
|
|
270
271
|
}
|
|
271
272
|
|
|
272
273
|
try {
|
|
@@ -281,8 +282,9 @@ export class JsonReporter extends BaseReporter {
|
|
|
281
282
|
|
|
282
283
|
writeFileSync(this.outputPath, jsonString, 'utf8');
|
|
283
284
|
} catch (error) {
|
|
284
|
-
throw new
|
|
285
|
+
throw new ReporterOutputError(
|
|
285
286
|
`Failed to write JSON output to ${this.outputPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
287
|
+
{ cause: error },
|
|
286
288
|
);
|
|
287
289
|
}
|
|
288
290
|
}
|
|
@@ -15,6 +15,11 @@ import type {
|
|
|
15
15
|
TaskResult,
|
|
16
16
|
} from '../types/index.js';
|
|
17
17
|
|
|
18
|
+
import {
|
|
19
|
+
ReporterAlreadyRegisteredError,
|
|
20
|
+
UnknownReporterError,
|
|
21
|
+
} from '../errors/index.js';
|
|
22
|
+
|
|
18
23
|
/**
|
|
19
24
|
* Base abstract reporter class providing common functionality
|
|
20
25
|
*/
|
|
@@ -301,7 +306,7 @@ export class ModestBenchReporterRegistry implements ReporterRegistry {
|
|
|
301
306
|
}
|
|
302
307
|
|
|
303
308
|
if (missing.length > 0) {
|
|
304
|
-
throw new
|
|
309
|
+
throw new UnknownReporterError(
|
|
305
310
|
`Unknown reporters: ${missing.join(', ')}. Available: ${Array.from(this.reporters.keys()).join(', ')}`,
|
|
306
311
|
);
|
|
307
312
|
}
|
|
@@ -328,7 +333,9 @@ export class ModestBenchReporterRegistry implements ReporterRegistry {
|
|
|
328
333
|
*/
|
|
329
334
|
register(name: string, reporter: Reporter): void {
|
|
330
335
|
if (this.reporters.has(name)) {
|
|
331
|
-
throw new
|
|
336
|
+
throw new ReporterAlreadyRegisteredError(
|
|
337
|
+
`Reporter with name "${name}" is already registered`,
|
|
338
|
+
);
|
|
332
339
|
}
|
|
333
340
|
this.reporters.set(name, reporter);
|
|
334
341
|
}
|
package/src/reporters/simple.ts
CHANGED
|
@@ -91,7 +91,7 @@ export class SimpleReporter extends BaseReporter {
|
|
|
91
91
|
console.log(`${symbols.cross} Failed: ${totalFailed}`);
|
|
92
92
|
console.log(`${symbols.checkmark} Passed: ${totalPassed}`);
|
|
93
93
|
} else {
|
|
94
|
-
console.log(`${symbols.checkmark} All
|
|
94
|
+
console.log(`${symbols.checkmark} All tasks passed: ${totalPassed}`);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
console.log(`- Files: ${totalFiles}`);
|
package/src/storage/history.ts
CHANGED
|
@@ -23,6 +23,16 @@ import type {
|
|
|
23
23
|
RetentionPolicy,
|
|
24
24
|
} from '../types/index.js';
|
|
25
25
|
|
|
26
|
+
import { ErrorCodes } from '../constants.js';
|
|
27
|
+
import {
|
|
28
|
+
type ModestBenchError,
|
|
29
|
+
StorageCorruptionError,
|
|
30
|
+
StorageError,
|
|
31
|
+
StorageIndexError,
|
|
32
|
+
StorageSpaceError,
|
|
33
|
+
UnsupportedExportFormatError,
|
|
34
|
+
} from '../errors/index.js';
|
|
35
|
+
|
|
26
36
|
/**
|
|
27
37
|
* Index entry for stored benchmark runs
|
|
28
38
|
*/
|
|
@@ -166,8 +176,9 @@ export class FileHistoryStorage implements HistoryStorage {
|
|
|
166
176
|
removedRuns: entriesToRemove.length,
|
|
167
177
|
};
|
|
168
178
|
} catch (error) {
|
|
169
|
-
throw new
|
|
179
|
+
throw new StorageError(
|
|
170
180
|
`Failed to cleanup storage: ${error instanceof Error ? error.message : String(error)}`,
|
|
181
|
+
{ cause: error },
|
|
171
182
|
);
|
|
172
183
|
}
|
|
173
184
|
}
|
|
@@ -184,11 +195,21 @@ export class FileHistoryStorage implements HistoryStorage {
|
|
|
184
195
|
} else if (format === 'csv') {
|
|
185
196
|
return this.exportToCsv(runs);
|
|
186
197
|
} else {
|
|
187
|
-
throw new
|
|
198
|
+
throw new UnsupportedExportFormatError(
|
|
199
|
+
`Unsupported export format: ${format}`,
|
|
200
|
+
);
|
|
188
201
|
}
|
|
189
202
|
} catch (error) {
|
|
190
|
-
throw
|
|
203
|
+
// Re-throw our custom errors
|
|
204
|
+
if (
|
|
205
|
+
(error as ModestBenchError).code ===
|
|
206
|
+
ErrorCodes.STORAGE_EXPORT_UNSUPPORTED
|
|
207
|
+
) {
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
210
|
+
throw new StorageError(
|
|
191
211
|
`Failed to export data: ${error instanceof Error ? error.message : String(error)}`,
|
|
212
|
+
{ cause: error },
|
|
192
213
|
);
|
|
193
214
|
}
|
|
194
215
|
}
|
|
@@ -207,8 +228,9 @@ export class FileHistoryStorage implements HistoryStorage {
|
|
|
207
228
|
summary: entry.summary,
|
|
208
229
|
}));
|
|
209
230
|
} catch (error) {
|
|
210
|
-
throw new
|
|
231
|
+
throw new StorageIndexError(
|
|
211
232
|
`Failed to get storage index: ${error instanceof Error ? error.message : String(error)}`,
|
|
233
|
+
{ cause: error },
|
|
212
234
|
);
|
|
213
235
|
}
|
|
214
236
|
}
|
|
@@ -286,13 +308,20 @@ export class FileHistoryStorage implements HistoryStorage {
|
|
|
286
308
|
|
|
287
309
|
// Validate the loaded run
|
|
288
310
|
if (!FileHistoryStorage.isValidBenchmarkRun(run)) {
|
|
289
|
-
throw new
|
|
311
|
+
throw new StorageCorruptionError(
|
|
312
|
+
`Invalid benchmark run data in file ${entry.filename}`,
|
|
313
|
+
);
|
|
290
314
|
}
|
|
291
315
|
|
|
292
316
|
return run;
|
|
293
317
|
} catch (error) {
|
|
294
|
-
throw
|
|
318
|
+
// Re-throw our custom errors
|
|
319
|
+
if ((error as ModestBenchError).code === ErrorCodes.STORAGE_CORRUPTION) {
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
322
|
+
throw new StorageError(
|
|
295
323
|
`Failed to load benchmark run ${id}: ${error instanceof Error ? error.message : String(error)}`,
|
|
324
|
+
{ cause: error },
|
|
296
325
|
);
|
|
297
326
|
}
|
|
298
327
|
}
|
|
@@ -362,8 +391,16 @@ export class FileHistoryStorage implements HistoryStorage {
|
|
|
362
391
|
|
|
363
392
|
return runs;
|
|
364
393
|
} catch (error) {
|
|
365
|
-
throw
|
|
394
|
+
// Re-throw our custom errors (from loadRun)
|
|
395
|
+
if (
|
|
396
|
+
error instanceof StorageError ||
|
|
397
|
+
error instanceof StorageCorruptionError
|
|
398
|
+
) {
|
|
399
|
+
throw error;
|
|
400
|
+
}
|
|
401
|
+
throw new StorageError(
|
|
366
402
|
`Failed to query benchmark runs: ${error instanceof Error ? error.message : String(error)}`,
|
|
403
|
+
{ cause: error },
|
|
367
404
|
);
|
|
368
405
|
}
|
|
369
406
|
}
|
|
@@ -384,7 +421,7 @@ export class FileHistoryStorage implements HistoryStorage {
|
|
|
384
421
|
|
|
385
422
|
// Check file size limit
|
|
386
423
|
if (Buffer.byteLength(data, 'utf8') > this.maxFileSize) {
|
|
387
|
-
throw new
|
|
424
|
+
throw new StorageSpaceError(
|
|
388
425
|
`Benchmark run data exceeds maximum file size of ${this.maxFileSize} bytes`,
|
|
389
426
|
);
|
|
390
427
|
}
|
|
@@ -395,8 +432,16 @@ export class FileHistoryStorage implements HistoryStorage {
|
|
|
395
432
|
// Update the index
|
|
396
433
|
await this.updateIndex(run, filename, Buffer.byteLength(data, 'utf8'));
|
|
397
434
|
} catch (error) {
|
|
398
|
-
throw
|
|
435
|
+
// Re-throw our custom errors
|
|
436
|
+
if (
|
|
437
|
+
(error as ModestBenchError).code ===
|
|
438
|
+
ErrorCodes.STORAGE_INSUFFICIENT_SPACE
|
|
439
|
+
) {
|
|
440
|
+
throw error;
|
|
441
|
+
}
|
|
442
|
+
throw new StorageError(
|
|
399
443
|
`Failed to save benchmark run: ${error instanceof Error ? error.message : String(error)}`,
|
|
444
|
+
{ cause: error },
|
|
400
445
|
);
|
|
401
446
|
}
|
|
402
447
|
}
|
|
@@ -522,8 +567,9 @@ export class FileHistoryStorage implements HistoryStorage {
|
|
|
522
567
|
|
|
523
568
|
return this.index; // We just assigned it, so it's not null
|
|
524
569
|
} catch (error) {
|
|
525
|
-
throw new
|
|
570
|
+
throw new StorageIndexError(
|
|
526
571
|
`Failed to load storage index: ${error instanceof Error ? error.message : String(error)}`,
|
|
572
|
+
{ cause: error },
|
|
527
573
|
);
|
|
528
574
|
}
|
|
529
575
|
}
|
|
@@ -559,8 +605,9 @@ export class FileHistoryStorage implements HistoryStorage {
|
|
|
559
605
|
const data = JSON.stringify(this.index, null, 2);
|
|
560
606
|
writeFileSync(this.indexFile, data, 'utf8');
|
|
561
607
|
} catch (error) {
|
|
562
|
-
throw new
|
|
608
|
+
throw new StorageIndexError(
|
|
563
609
|
`Failed to save storage index: ${error instanceof Error ? error.message : String(error)}`,
|
|
610
|
+
{ cause: error },
|
|
564
611
|
);
|
|
565
612
|
}
|
|
566
613
|
}
|
package/src/types/interfaces.ts
CHANGED
|
@@ -9,9 +9,6 @@
|
|
|
9
9
|
import type {
|
|
10
10
|
BenchmarkFile,
|
|
11
11
|
BenchmarkRun,
|
|
12
|
-
ErrorContext,
|
|
13
|
-
ErrorStats,
|
|
14
|
-
ExecutionError,
|
|
15
12
|
FileResult,
|
|
16
13
|
ModestBenchConfig,
|
|
17
14
|
SuiteResult,
|
|
@@ -102,46 +99,6 @@ export interface CsvReporter extends Reporter {
|
|
|
102
99
|
readonly includeHeaders: boolean;
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
/**
|
|
106
|
-
* Error management interface for handling execution errors
|
|
107
|
-
*/
|
|
108
|
-
export interface ErrorManager {
|
|
109
|
-
/**
|
|
110
|
-
* Clear error history
|
|
111
|
-
*/
|
|
112
|
-
clearStats(): void;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Format error for display
|
|
116
|
-
*/
|
|
117
|
-
formatError(error: ExecutionError): string;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Get error code for a given error
|
|
121
|
-
*/
|
|
122
|
-
getErrorCode(error: Error, context: ErrorContext): string;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Get error statistics
|
|
126
|
-
*/
|
|
127
|
-
getStats(): ErrorStats;
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Handle an execution error
|
|
131
|
-
*/
|
|
132
|
-
handleError(error: Error, context: ErrorContext): ExecutionError;
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Check if an error is recoverable
|
|
136
|
-
*/
|
|
137
|
-
isRecoverable(error: ExecutionError): boolean;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Register error handler callback
|
|
141
|
-
*/
|
|
142
|
-
onError(handler: (error: ExecutionError) => void): void;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
102
|
/**
|
|
146
103
|
* File loader interface for benchmark discovery and loading
|
|
147
104
|
*/
|