-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPipelineError.ts
42 lines (38 loc) · 1.09 KB
/
PipelineError.ts
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
import { PipelineMetadata } from "../types";
/**
* An error when executing a pipeline.
*/
export class PipelineError<
A extends object,
C extends object,
R extends object,
> extends Error {
/**
* Retrieve data from the pipeline execution that caused this error. This includes the Context, Metadata, and any Results from the pipeline so far.
*/
public getPipelineData() {
return this.pipelineData;
}
private pipelineData: {
context?: C;
results: Partial<R>;
metadata: PipelineMetadata<A>;
};
constructor(
message: string,
protected pipelineContext: C | undefined,
protected pipelineResults: Partial<R>,
protected pipelineMetadata: PipelineMetadata<A>,
/** A throwable that caused this exception */
public override readonly cause?: unknown,
) {
// prepend the message with the pipeline name
super(`[${pipelineMetadata.name}] ${message}`);
// store pipeline data so it can be caught/retrieved later
this.pipelineData = {
context: pipelineContext,
metadata: pipelineMetadata,
results: pipelineResults,
};
}
}