-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.js
More file actions
51 lines (46 loc) · 1.41 KB
/
Copy patherrors.js
File metadata and controls
51 lines (46 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Standardized error classes for the preprocessor
*/
export class PreprocessorError extends Error {
constructor(message, code, details = {}) {
super(message);
this.name = 'PreprocessorError';
this.code = code;
this.details = details;
}
}
export class ModelNotLoadedError extends PreprocessorError {
constructor(operation) {
super(
`Model not loaded. Call loadModel() before using ${operation}.`,
'MODEL_NOT_LOADED',
{ operation }
);
this.name = 'ModelNotLoadedError';
}
}
export class ValidationError extends PreprocessorError {
constructor(message, issues = []) {
super(message, 'VALIDATION_FAILED', { issues });
this.name = 'ValidationError';
}
}
export class InferenceError extends PreprocessorError {
constructor(message, originalError = null) {
const fullMessage = originalError
? `Inference failed: ${message} (${originalError.message})`
: `Inference failed: ${message}`;
super(
fullMessage,
'INFERENCE_FAILED',
{ originalError: originalError?.message }
);
this.name = 'InferenceError';
}
}
export class ConfigurationError extends PreprocessorError {
constructor(message, field) {
super(message, 'CONFIGURATION_ERROR', { field });
this.name = 'ConfigurationError';
}
}