|
1 | | -import type { MessageHint, MessageProcessor, ProcessingPayload } from '@hawk.so/core'; |
| 1 | +import type { ErrorSnapshot, MessageProcessor, ProcessingPayload } from '@hawk.so/core'; |
2 | 2 |
|
3 | 3 | /** |
4 | 4 | * Appends `RAW_EVENT_DATA` to the event addons for debug purposes. |
5 | 5 | */ |
6 | 6 | export class DebugAddonMessageProcessor implements MessageProcessor<'errors/javascript'> { |
7 | 7 | /** |
8 | | - * Writes name, message, and stack from `hint.error` into `payload.addons.RAW_EVENT_DATA`. |
9 | | - * Skips if hint error is not Error instance. |
| 8 | + * Writes name, message, and stack from `snapshot.error` into `payload.addons.RAW_EVENT_DATA`. |
| 9 | + * Skips if snapshot error is missing or not Error instance. |
10 | 10 | * |
11 | 11 | * @param payload - event message payload to enrich |
12 | | - * @param hint - hint carrying original caught error |
| 12 | + * @param snapshot - snapshot carrying original caught error |
13 | 13 | * @returns modified payload with RAW_EVENT_DATA set, or original payload unchanged |
14 | 14 | */ |
15 | 15 | public apply( |
16 | 16 | payload: ProcessingPayload<'errors/javascript'>, |
17 | | - hint?: MessageHint |
| 17 | + snapshot?: ErrorSnapshot |
18 | 18 | ): ProcessingPayload<'errors/javascript'> | null { |
19 | | - if (!(hint?.error instanceof Error)) { |
| 19 | + if (!(snapshot?.error instanceof Error)) { |
20 | 20 | return payload; |
21 | 21 | } |
22 | 22 |
|
23 | 23 | payload.addons.RAW_EVENT_DATA = { |
24 | | - name: hint.error.name, |
25 | | - message: hint.error.message, |
26 | | - stack: hint.error.stack ?? '', |
| 24 | + name: snapshot.error.name, |
| 25 | + message: snapshot.error.message, |
| 26 | + stack: snapshot.error.stack ?? '', |
27 | 27 | }; |
28 | 28 |
|
29 | 29 | return payload; |
|
0 commit comments