@zdavison/matador 2.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/cli.ts +453 -0
- package/dist/checkpoint/context.d.ts +59 -0
- package/dist/checkpoint/context.d.ts.map +1 -0
- package/dist/checkpoint/context.js +140 -0
- package/dist/checkpoint/context.test.d.ts +2 -0
- package/dist/checkpoint/context.test.d.ts.map +1 -0
- package/dist/checkpoint/context.test.js +424 -0
- package/dist/checkpoint/index.d.ts +7 -0
- package/dist/checkpoint/index.d.ts.map +1 -0
- package/dist/checkpoint/index.js +6 -0
- package/dist/checkpoint/stores/memory.d.ts +29 -0
- package/dist/checkpoint/stores/memory.d.ts.map +1 -0
- package/dist/checkpoint/stores/memory.js +39 -0
- package/dist/checkpoint/stores/noop.d.ts +14 -0
- package/dist/checkpoint/stores/noop.d.ts.map +1 -0
- package/dist/checkpoint/stores/noop.js +18 -0
- package/dist/checkpoint/stores/stores.test.d.ts +2 -0
- package/dist/checkpoint/stores/stores.test.d.ts.map +1 -0
- package/dist/checkpoint/stores/stores.test.js +146 -0
- package/dist/checkpoint/types.d.ts +119 -0
- package/dist/checkpoint/types.d.ts.map +1 -0
- package/dist/checkpoint/types.js +1 -0
- package/dist/codec/codec.d.ts +29 -0
- package/dist/codec/codec.d.ts.map +1 -0
- package/dist/codec/codec.js +15 -0
- package/dist/codec/header-aware-codec.d.ts +36 -0
- package/dist/codec/header-aware-codec.d.ts.map +1 -0
- package/dist/codec/header-aware-codec.js +1 -0
- package/dist/codec/index.d.ts +6 -0
- package/dist/codec/index.d.ts.map +1 -0
- package/dist/codec/index.js +3 -0
- package/dist/codec/json-codec.d.ts +13 -0
- package/dist/codec/json-codec.d.ts.map +1 -0
- package/dist/codec/json-codec.js +64 -0
- package/dist/codec/rabbitmq-codec.d.ts +28 -0
- package/dist/codec/rabbitmq-codec.d.ts.map +1 -0
- package/dist/codec/rabbitmq-codec.js +242 -0
- package/dist/codec/rabbitmq-codec.test.d.ts +2 -0
- package/dist/codec/rabbitmq-codec.test.d.ts.map +1 -0
- package/dist/codec/rabbitmq-codec.test.js +433 -0
- package/dist/core/fanout.d.ts +59 -0
- package/dist/core/fanout.d.ts.map +1 -0
- package/dist/core/fanout.js +121 -0
- package/dist/core/fanout.test.d.ts +2 -0
- package/dist/core/fanout.test.d.ts.map +1 -0
- package/dist/core/fanout.test.js +1055 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +3 -0
- package/dist/core/matador.d.ts +133 -0
- package/dist/core/matador.d.ts.map +1 -0
- package/dist/core/matador.js +222 -0
- package/dist/core/matador.test.d.ts +2 -0
- package/dist/core/matador.test.d.ts.map +1 -0
- package/dist/core/matador.test.js +446 -0
- package/dist/core/shutdown.d.ts +78 -0
- package/dist/core/shutdown.d.ts.map +1 -0
- package/dist/core/shutdown.js +111 -0
- package/dist/core/shutdown.test.d.ts +2 -0
- package/dist/core/shutdown.test.d.ts.map +1 -0
- package/dist/core/shutdown.test.js +524 -0
- package/dist/errors/checkpoint-errors.d.ts +30 -0
- package/dist/errors/checkpoint-errors.d.ts.map +1 -0
- package/dist/errors/checkpoint-errors.js +49 -0
- package/dist/errors/has-description.d.ts +18 -0
- package/dist/errors/has-description.d.ts.map +1 -0
- package/dist/errors/has-description.js +9 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +22 -0
- package/dist/errors/matador-errors.d.ts +183 -0
- package/dist/errors/matador-errors.d.ts.map +1 -0
- package/dist/errors/matador-errors.js +376 -0
- package/dist/errors/retry-errors.d.ts +67 -0
- package/dist/errors/retry-errors.d.ts.map +1 -0
- package/dist/errors/retry-errors.js +108 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/safe-hooks.d.ts +34 -0
- package/dist/hooks/safe-hooks.d.ts.map +1 -0
- package/dist/hooks/safe-hooks.js +135 -0
- package/dist/hooks/types.d.ts +189 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +9 -0
- package/dist/index.cjs +3156 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline/index.d.ts +3 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +1 -0
- package/dist/pipeline/pipeline.d.ts +60 -0
- package/dist/pipeline/pipeline.d.ts.map +1 -0
- package/dist/pipeline/pipeline.js +261 -0
- package/dist/pipeline/pipeline.test.d.ts +2 -0
- package/dist/pipeline/pipeline.test.d.ts.map +1 -0
- package/dist/pipeline/pipeline.test.js +1065 -0
- package/dist/retry/index.d.ts +4 -0
- package/dist/retry/index.d.ts.map +1 -0
- package/dist/retry/index.js +1 -0
- package/dist/retry/policy.d.ts +43 -0
- package/dist/retry/policy.d.ts.map +1 -0
- package/dist/retry/policy.js +1 -0
- package/dist/retry/standard-policy.d.ts +44 -0
- package/dist/retry/standard-policy.d.ts.map +1 -0
- package/dist/retry/standard-policy.js +102 -0
- package/dist/retry/standard-policy.test.d.ts +2 -0
- package/dist/retry/standard-policy.test.d.ts.map +1 -0
- package/dist/retry/standard-policy.test.js +190 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +2 -0
- package/dist/schema/registry.d.ts +63 -0
- package/dist/schema/registry.d.ts.map +1 -0
- package/dist/schema/registry.js +171 -0
- package/dist/schema/registry.test.d.ts +2 -0
- package/dist/schema/registry.test.d.ts.map +1 -0
- package/dist/schema/registry.test.js +278 -0
- package/dist/schema/types.d.ts +158 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +74 -0
- package/dist/schema/types.test.d.ts +2 -0
- package/dist/schema/types.test.d.ts.map +1 -0
- package/dist/schema/types.test.js +243 -0
- package/dist/topology/builder.d.ts +66 -0
- package/dist/topology/builder.d.ts.map +1 -0
- package/dist/topology/builder.js +156 -0
- package/dist/topology/builder.test.d.ts +2 -0
- package/dist/topology/builder.test.d.ts.map +1 -0
- package/dist/topology/builder.test.js +222 -0
- package/dist/topology/index.d.ts +5 -0
- package/dist/topology/index.d.ts.map +1 -0
- package/dist/topology/index.js +2 -0
- package/dist/topology/types.d.ts +76 -0
- package/dist/topology/types.d.ts.map +1 -0
- package/dist/topology/types.js +18 -0
- package/dist/transport/capabilities.d.ts +66 -0
- package/dist/transport/capabilities.d.ts.map +1 -0
- package/dist/transport/capabilities.js +18 -0
- package/dist/transport/connection-manager.d.ts +95 -0
- package/dist/transport/connection-manager.d.ts.map +1 -0
- package/dist/transport/connection-manager.js +144 -0
- package/dist/transport/index.d.ts +11 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +5 -0
- package/dist/transport/local/local-transport.d.ts +62 -0
- package/dist/transport/local/local-transport.d.ts.map +1 -0
- package/dist/transport/local/local-transport.js +241 -0
- package/dist/transport/local/local-transport.test.d.ts +2 -0
- package/dist/transport/local/local-transport.test.d.ts.map +1 -0
- package/dist/transport/local/local-transport.test.js +192 -0
- package/dist/transport/multi/multi-transport.d.ts +94 -0
- package/dist/transport/multi/multi-transport.d.ts.map +1 -0
- package/dist/transport/multi/multi-transport.js +184 -0
- package/dist/transport/multi/multi-transport.test.d.ts +2 -0
- package/dist/transport/multi/multi-transport.test.d.ts.map +1 -0
- package/dist/transport/multi/multi-transport.test.js +236 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.d.ts +73 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.d.ts.map +1 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.js +518 -0
- package/dist/transport/transport.d.ts +152 -0
- package/dist/transport/transport.d.ts.map +1 -0
- package/dist/transport/transport.js +1 -0
- package/dist/types/common.d.ts +41 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +12 -0
- package/dist/types/envelope.d.ts +82 -0
- package/dist/types/envelope.d.ts.map +1 -0
- package/dist/types/envelope.js +36 -0
- package/dist/types/event.d.ts +96 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/event.js +26 -0
- package/dist/types/event.test.d.ts +2 -0
- package/dist/types/event.test.d.ts.map +1 -0
- package/dist/types/event.test.js +130 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/subscriber.d.ts +207 -0
- package/dist/types/subscriber.d.ts.map +1 -0
- package/dist/types/subscriber.js +99 -0
- package/examples/config.ts +126 -0
- package/examples/event.ts +26 -0
- package/examples/order-event.json +19 -0
- package/package.json +66 -0
- package/src/checkpoint/context.test.ts +510 -0
- package/src/checkpoint/context.ts +213 -0
- package/src/checkpoint/index.ts +30 -0
- package/src/checkpoint/stores/memory.ts +47 -0
- package/src/checkpoint/stores/noop.ts +22 -0
- package/src/checkpoint/stores/stores.test.ts +177 -0
- package/src/checkpoint/types.ts +147 -0
- package/src/codec/codec.ts +42 -0
- package/src/codec/header-aware-codec.ts +41 -0
- package/src/codec/index.ts +11 -0
- package/src/codec/json-codec.ts +69 -0
- package/src/codec/rabbitmq-codec.test.ts +516 -0
- package/src/codec/rabbitmq-codec.ts +336 -0
- package/src/core/fanout.test.ts +1351 -0
- package/src/core/fanout.ts +184 -0
- package/src/core/index.ts +12 -0
- package/src/core/matador.test.ts +575 -0
- package/src/core/matador.ts +344 -0
- package/src/core/shutdown.test.ts +853 -0
- package/src/core/shutdown.ts +165 -0
- package/src/errors/checkpoint-errors.ts +62 -0
- package/src/errors/has-description.ts +25 -0
- package/src/errors/index.ts +57 -0
- package/src/errors/matador-errors.ts +477 -0
- package/src/errors/retry-errors.ts +134 -0
- package/src/hooks/index.ts +15 -0
- package/src/hooks/safe-hooks.ts +223 -0
- package/src/hooks/types.ts +248 -0
- package/src/index.ts +231 -0
- package/src/pipeline/index.ts +2 -0
- package/src/pipeline/pipeline.test.ts +1317 -0
- package/src/pipeline/pipeline.ts +371 -0
- package/src/retry/index.ts +4 -0
- package/src/retry/policy.ts +46 -0
- package/src/retry/standard-policy.test.ts +282 -0
- package/src/retry/standard-policy.ts +156 -0
- package/src/schema/index.ts +16 -0
- package/src/schema/registry.test.ts +339 -0
- package/src/schema/registry.ts +226 -0
- package/src/schema/types.test.ts +281 -0
- package/src/schema/types.ts +217 -0
- package/src/topology/builder.test.ts +275 -0
- package/src/topology/builder.ts +199 -0
- package/src/topology/index.ts +15 -0
- package/src/topology/types.ts +109 -0
- package/src/transport/capabilities.ts +88 -0
- package/src/transport/connection-manager.ts +218 -0
- package/src/transport/index.ts +42 -0
- package/src/transport/local/local-transport.test.ts +262 -0
- package/src/transport/local/local-transport.ts +327 -0
- package/src/transport/multi/multi-transport.test.ts +320 -0
- package/src/transport/multi/multi-transport.ts +294 -0
- package/src/transport/rabbitmq/rabbitmq-transport.ts +753 -0
- package/src/transport/transport.ts +200 -0
- package/src/types/common.ts +53 -0
- package/src/types/envelope.ts +152 -0
- package/src/types/event.test.ts +157 -0
- package/src/types/event.ts +118 -0
- package/src/types/index.ts +52 -0
- package/src/types/subscriber.ts +310 -0
- package/test/e2e/multi-transport.e2e.test.ts +236 -0
- package/test/e2e/rabbitmq-transport.e2e.test.ts +327 -0
- package/test/e2e/transport-compliance.e2e.test.ts +505 -0
- package/test/integration/matador.integration.test.ts +634 -0
- package/tsconfig.json +29 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsup.config.ts +13 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for all Matador errors.
|
|
3
|
+
* All errors have a unique name that appears in monitoring tools (e.g., DataDog)
|
|
4
|
+
* and a description explaining the error and actions to resolve it.
|
|
5
|
+
*
|
|
6
|
+
* The `name` property is automatically set to the class name for proper
|
|
7
|
+
* identification in error monitoring and logging systems.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class MatadorError extends Error {
|
|
10
|
+
/**
|
|
11
|
+
* Error class name (e.g., "NotStartedError", "TransportNotConnectedError").
|
|
12
|
+
* This is preserved during serialization for error monitoring tools.
|
|
13
|
+
*/
|
|
14
|
+
readonly name: string;
|
|
15
|
+
/**
|
|
16
|
+
* Human-readable description explaining what went wrong and
|
|
17
|
+
* what ACTION the user should take to resolve the issue.
|
|
18
|
+
*/
|
|
19
|
+
abstract readonly description: string;
|
|
20
|
+
constructor(message: string);
|
|
21
|
+
/**
|
|
22
|
+
* Returns a serializable representation for logging/monitoring.
|
|
23
|
+
*/
|
|
24
|
+
toJSON(): Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Thrown when attempting to use Matador before calling start().
|
|
28
|
+
*/
|
|
29
|
+
export declare class NotStartedError extends MatadorError {
|
|
30
|
+
readonly description: string;
|
|
31
|
+
constructor(operation?: string);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Thrown when attempting to dispatch events during shutdown.
|
|
35
|
+
*/
|
|
36
|
+
export declare class ShutdownInProgressError extends MatadorError {
|
|
37
|
+
readonly description: string;
|
|
38
|
+
constructor();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Thrown when a transport operation is attempted but the transport is not connected.
|
|
42
|
+
*/
|
|
43
|
+
export declare class TransportNotConnectedError extends MatadorError {
|
|
44
|
+
readonly transportName: string;
|
|
45
|
+
readonly description: string;
|
|
46
|
+
constructor(transportName: string, operation?: string);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Thrown when the transport has been closed (during shutdown).
|
|
50
|
+
*/
|
|
51
|
+
export declare class TransportClosedError extends MatadorError {
|
|
52
|
+
readonly transportName: string;
|
|
53
|
+
readonly description: string;
|
|
54
|
+
constructor(transportName: string);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Thrown when all transports in a fallback chain fail.
|
|
58
|
+
*/
|
|
59
|
+
export declare class AllTransportsFailedError extends MatadorError {
|
|
60
|
+
readonly queue: string;
|
|
61
|
+
readonly errors: readonly Error[];
|
|
62
|
+
readonly description: string;
|
|
63
|
+
constructor(queue: string, errors: readonly Error[]);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Thrown when sending a message to the transport fails.
|
|
67
|
+
*/
|
|
68
|
+
export declare class TransportSendError extends MatadorError {
|
|
69
|
+
readonly queue: string;
|
|
70
|
+
readonly cause: Error;
|
|
71
|
+
readonly description: string;
|
|
72
|
+
constructor(queue: string, cause: Error);
|
|
73
|
+
toJSON(): Record<string, unknown>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Thrown when delayed messages are requested but the plugin is not available.
|
|
77
|
+
*/
|
|
78
|
+
export declare class DelayedMessagesNotSupportedError extends MatadorError {
|
|
79
|
+
readonly transportName: string;
|
|
80
|
+
readonly description: string;
|
|
81
|
+
constructor(transportName: string);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Thrown when an event is not registered in the schema.
|
|
85
|
+
*/
|
|
86
|
+
export declare class EventNotRegisteredError extends MatadorError {
|
|
87
|
+
readonly eventKey: string;
|
|
88
|
+
readonly description: string;
|
|
89
|
+
constructor(eventKey: string);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Thrown when a subscriber is not found for an event.
|
|
93
|
+
*/
|
|
94
|
+
export declare class SubscriberNotRegisteredError extends MatadorError {
|
|
95
|
+
readonly subscriberName: string;
|
|
96
|
+
readonly eventKey?: string | undefined;
|
|
97
|
+
readonly description: string;
|
|
98
|
+
constructor(subscriberName: string, eventKey?: string | undefined);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Thrown when no subscribers exist for an event during fanout.
|
|
102
|
+
*/
|
|
103
|
+
export declare class NoSubscribersExistError extends MatadorError {
|
|
104
|
+
readonly eventKey: string;
|
|
105
|
+
readonly description: string;
|
|
106
|
+
constructor(eventKey: string);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Thrown when the schema configuration is invalid.
|
|
110
|
+
*/
|
|
111
|
+
export declare class InvalidSchemaError extends MatadorError {
|
|
112
|
+
readonly cause?: string | undefined;
|
|
113
|
+
readonly description: string;
|
|
114
|
+
constructor(message: string, cause?: string | undefined);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Thrown when a subscriber is a stub but is being processed locally.
|
|
118
|
+
*/
|
|
119
|
+
export declare class SubscriberIsStubError extends MatadorError {
|
|
120
|
+
readonly subscriberName: string;
|
|
121
|
+
readonly description: string;
|
|
122
|
+
constructor(subscriberName: string);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Thrown when a LocalTransport tries to process a stub subscriber.
|
|
126
|
+
*/
|
|
127
|
+
export declare class LocalTransportCannotProcessStubError extends MatadorError {
|
|
128
|
+
readonly subscriberName: string;
|
|
129
|
+
readonly description: string;
|
|
130
|
+
constructor(subscriberName: string);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Thrown when a queue is not found or not created.
|
|
134
|
+
*/
|
|
135
|
+
export declare class QueueNotFoundError extends MatadorError {
|
|
136
|
+
readonly queueName: string;
|
|
137
|
+
readonly description: string;
|
|
138
|
+
constructor(queueName: string);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Thrown when an event is invalid or malformed.
|
|
142
|
+
*/
|
|
143
|
+
export declare class InvalidEventError extends MatadorError {
|
|
144
|
+
readonly cause?: string | undefined;
|
|
145
|
+
readonly description: string;
|
|
146
|
+
constructor(message: string, cause?: string | undefined);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Thrown when a message has been redelivered too many times (poison message).
|
|
150
|
+
*/
|
|
151
|
+
export declare class MessageMaybePoisonedError extends MatadorError {
|
|
152
|
+
readonly eventId: string;
|
|
153
|
+
readonly deliveryCount: number;
|
|
154
|
+
readonly maxDeliveries: number;
|
|
155
|
+
readonly description: string;
|
|
156
|
+
constructor(eventId: string, deliveryCount: number, maxDeliveries: number);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Thrown when a non-idempotent message cannot be retried after redelivery.
|
|
160
|
+
*/
|
|
161
|
+
export declare class IdempotentMessageCannotRetryError extends MatadorError {
|
|
162
|
+
readonly eventId: string;
|
|
163
|
+
readonly subscriberName: string;
|
|
164
|
+
readonly description: string;
|
|
165
|
+
constructor(eventId: string, subscriberName: string);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Thrown when an operation times out.
|
|
169
|
+
*/
|
|
170
|
+
export declare class TimeoutError extends MatadorError {
|
|
171
|
+
readonly operation: string;
|
|
172
|
+
readonly timeoutMs: number;
|
|
173
|
+
readonly description: string;
|
|
174
|
+
constructor(operation: string, timeoutMs: number);
|
|
175
|
+
}
|
|
176
|
+
export declare function isMatadorError(error: unknown): error is MatadorError;
|
|
177
|
+
export declare function isNotStartedError(error: unknown): error is NotStartedError;
|
|
178
|
+
export declare function isTransportNotConnectedError(error: unknown): error is TransportNotConnectedError;
|
|
179
|
+
export declare function isEventNotRegisteredError(error: unknown): error is EventNotRegisteredError;
|
|
180
|
+
export declare function isSubscriberNotRegisteredError(error: unknown): error is SubscriberNotRegisteredError;
|
|
181
|
+
export declare function isMessageMaybePoisonedError(error: unknown): error is MessageMaybePoisonedError;
|
|
182
|
+
export declare function isIdempotentMessageCannotRetryError(error: unknown): error is IdempotentMessageCannotRetryError;
|
|
183
|
+
//# sourceMappingURL=matador-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matador-errors.d.ts","sourceRoot":"","sources":["../../src/errors/matador-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,8BAAsB,YAAa,SAAQ,KAAK;IAC9C;;;OAGG;IACH,SAAiB,IAAI,EAAE,MAAM,CAAC;IAE9B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,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oring tools (e.g., DataDog)
|
|
4
|
+
* and a description explaining the error and actions to resolve it.
|
|
5
|
+
*
|
|
6
|
+
* The `name` property is automatically set to the class name for proper
|
|
7
|
+
* identification in error monitoring and logging systems.
|
|
8
|
+
*/
|
|
9
|
+
export class MatadorError extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = this.constructor.name;
|
|
13
|
+
// Ensure name is preserved when serialized
|
|
14
|
+
Object.defineProperty(this, 'name', {
|
|
15
|
+
value: this.constructor.name,
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: false,
|
|
18
|
+
writable: false,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns a serializable representation for logging/monitoring.
|
|
23
|
+
*/
|
|
24
|
+
toJSON() {
|
|
25
|
+
return {
|
|
26
|
+
name: this.name,
|
|
27
|
+
message: this.message,
|
|
28
|
+
description: this.description,
|
|
29
|
+
stack: this.stack,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// Lifecycle Errors
|
|
35
|
+
// ============================================================================
|
|
36
|
+
/**
|
|
37
|
+
* Thrown when attempting to use Matador before calling start().
|
|
38
|
+
*/
|
|
39
|
+
export class NotStartedError extends MatadorError {
|
|
40
|
+
description = 'Matador has not been started. ' +
|
|
41
|
+
'ACTION: Call matador.start() before dispatching events or performing other operations. ' +
|
|
42
|
+
'Ensure start() completes successfully before using other methods.';
|
|
43
|
+
constructor(operation = 'operation') {
|
|
44
|
+
super(`Cannot perform ${operation}: Matador has not been started. Call start() first.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Thrown when attempting to dispatch events during shutdown.
|
|
49
|
+
*/
|
|
50
|
+
export class ShutdownInProgressError extends MatadorError {
|
|
51
|
+
description = 'Matador is shutting down and will not accept new events. ' +
|
|
52
|
+
'ACTION: Do not dispatch events after calling shutdown(). ' +
|
|
53
|
+
'If you need to send events, do so before initiating shutdown. ' +
|
|
54
|
+
'Consider implementing a pre-shutdown event flush if needed.';
|
|
55
|
+
constructor() {
|
|
56
|
+
super('Cannot dispatch events: Matador is shutting down.');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// ============================================================================
|
|
60
|
+
// Transport Errors
|
|
61
|
+
// ============================================================================
|
|
62
|
+
/**
|
|
63
|
+
* Thrown when a transport operation is attempted but the transport is not connected.
|
|
64
|
+
*/
|
|
65
|
+
export class TransportNotConnectedError extends MatadorError {
|
|
66
|
+
transportName;
|
|
67
|
+
description = 'The transport is not connected to the message broker. ' +
|
|
68
|
+
'ACTION: Ensure the transport is connected by calling transport.connect() or matador.start(). ' +
|
|
69
|
+
'Check that the broker (e.g., RabbitMQ) is running and accessible. ' +
|
|
70
|
+
'Verify connection settings (URL, credentials, network access).';
|
|
71
|
+
constructor(transportName, operation = 'operation') {
|
|
72
|
+
super(`Cannot perform ${operation}: Transport "${transportName}" is not connected. ` +
|
|
73
|
+
`Ensure connect() was called and the broker is accessible.`);
|
|
74
|
+
this.transportName = transportName;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Thrown when the transport has been closed (during shutdown).
|
|
79
|
+
*/
|
|
80
|
+
export class TransportClosedError extends MatadorError {
|
|
81
|
+
transportName;
|
|
82
|
+
description = 'The transport has been closed and will not accept new operations. ' +
|
|
83
|
+
'ACTION: This typically occurs during application shutdown. ' +
|
|
84
|
+
'If unexpected, check for early shutdown triggers. ' +
|
|
85
|
+
'Events sent after transport closure will be lost.';
|
|
86
|
+
constructor(transportName) {
|
|
87
|
+
super(`Transport "${transportName}" has been closed and will not accept new operations.`);
|
|
88
|
+
this.transportName = transportName;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Thrown when all transports in a fallback chain fail.
|
|
93
|
+
*/
|
|
94
|
+
export class AllTransportsFailedError extends MatadorError {
|
|
95
|
+
queue;
|
|
96
|
+
errors;
|
|
97
|
+
description = 'All transports failed to send the message. ' +
|
|
98
|
+
'ACTION: Check the health of all configured transports (primary and fallbacks). ' +
|
|
99
|
+
'Review the errors array for specific failure reasons. ' +
|
|
100
|
+
'Ensure at least one transport is properly configured and reachable. ' +
|
|
101
|
+
'Consider adding a LocalTransport as a last-resort fallback.';
|
|
102
|
+
constructor(queue, errors) {
|
|
103
|
+
super(`All transports failed to send message to queue "${queue}". ` +
|
|
104
|
+
`Errors: ${errors.map((e) => e.message).join('; ')}`);
|
|
105
|
+
this.queue = queue;
|
|
106
|
+
this.errors = errors;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Thrown when sending a message to the transport fails.
|
|
111
|
+
*/
|
|
112
|
+
export class TransportSendError extends MatadorError {
|
|
113
|
+
queue;
|
|
114
|
+
cause;
|
|
115
|
+
description = 'Failed to send a message through the transport. ' +
|
|
116
|
+
'ACTION: Check the underlying error for details. Common causes: ' +
|
|
117
|
+
'(1) Transport disconnected during send, ' +
|
|
118
|
+
'(2) Network issues between application and broker, ' +
|
|
119
|
+
'(3) Broker rejected the message (size, permissions, queue limits). ' +
|
|
120
|
+
'The message was NOT delivered and should be retried or logged.';
|
|
121
|
+
constructor(queue, cause) {
|
|
122
|
+
super(`Failed to send message to queue "${queue}": ${cause.message}`);
|
|
123
|
+
this.queue = queue;
|
|
124
|
+
this.cause = cause;
|
|
125
|
+
}
|
|
126
|
+
toJSON() {
|
|
127
|
+
return {
|
|
128
|
+
...super.toJSON(),
|
|
129
|
+
queue: this.queue,
|
|
130
|
+
cause: {
|
|
131
|
+
name: this.cause.name,
|
|
132
|
+
message: this.cause.message,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Thrown when delayed messages are requested but the plugin is not available.
|
|
139
|
+
*/
|
|
140
|
+
export class DelayedMessagesNotSupportedError extends MatadorError {
|
|
141
|
+
transportName;
|
|
142
|
+
description = 'Delayed messages were requested but the transport does not support them. ' +
|
|
143
|
+
'ACTION: For RabbitMQ, install the rabbitmq_delayed_message_exchange plugin. ' +
|
|
144
|
+
'Run: rabbitmq-plugins enable rabbitmq_delayed_message_exchange ' +
|
|
145
|
+
'Then restart RabbitMQ and reconnect. ' +
|
|
146
|
+
'Alternatively, remove delayMs from your event options if delays are not required.';
|
|
147
|
+
constructor(transportName) {
|
|
148
|
+
super(`Delayed messages require the RabbitMQ delayed message exchange plugin. ` +
|
|
149
|
+
`Install rabbitmq_delayed_message_exchange or remove delayMs from event options.`);
|
|
150
|
+
this.transportName = transportName;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// ============================================================================
|
|
154
|
+
// Schema & Configuration Errors
|
|
155
|
+
// ============================================================================
|
|
156
|
+
/**
|
|
157
|
+
* Thrown when an event is not registered in the schema.
|
|
158
|
+
*/
|
|
159
|
+
export class EventNotRegisteredError extends MatadorError {
|
|
160
|
+
eventKey;
|
|
161
|
+
description = 'The event type is not registered in the schema. ' +
|
|
162
|
+
'ACTION: Register the event using matador.register(EventClass, subscribers) before dispatching. ' +
|
|
163
|
+
'If this occurs during message consumption, it may indicate schema drift between services. ' +
|
|
164
|
+
'Ensure all services have matching schema registrations for shared events.';
|
|
165
|
+
constructor(eventKey) {
|
|
166
|
+
super(`Event "${eventKey}" is not registered in schema. ` +
|
|
167
|
+
`Register it using matador.register(EventClass, subscribers).`);
|
|
168
|
+
this.eventKey = eventKey;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Thrown when a subscriber is not found for an event.
|
|
173
|
+
*/
|
|
174
|
+
export class SubscriberNotRegisteredError extends MatadorError {
|
|
175
|
+
subscriberName;
|
|
176
|
+
eventKey;
|
|
177
|
+
description = 'The subscriber is not registered for this event in the schema. ' +
|
|
178
|
+
'ACTION: Ensure the subscriber is included in the registration for this event. ' +
|
|
179
|
+
'This may occur if: (1) The subscriber was removed from the schema but messages still exist, ' +
|
|
180
|
+
'(2) Schema drift between producer and consumer services, ' +
|
|
181
|
+
'(3) A deployment is in progress with different schema versions. ' +
|
|
182
|
+
'Check the dead-letter queue for affected messages.';
|
|
183
|
+
constructor(subscriberName, eventKey) {
|
|
184
|
+
super(`Subscriber "${subscriberName}" is not registered` +
|
|
185
|
+
(eventKey ? ` for event "${eventKey}"` : '') +
|
|
186
|
+
'. Check schema registration.');
|
|
187
|
+
this.subscriberName = subscriberName;
|
|
188
|
+
this.eventKey = eventKey;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Thrown when no subscribers exist for an event during fanout.
|
|
193
|
+
*/
|
|
194
|
+
export class NoSubscribersExistError extends MatadorError {
|
|
195
|
+
eventKey;
|
|
196
|
+
description = 'The event has no subscribers registered. ' +
|
|
197
|
+
'ACTION: Register at least one subscriber for this event type. ' +
|
|
198
|
+
'If subscribers were intentionally removed, consider also removing the event dispatch. ' +
|
|
199
|
+
'Events without subscribers are not useful and may indicate configuration issues.';
|
|
200
|
+
constructor(eventKey) {
|
|
201
|
+
super(`No subscribers registered for event "${eventKey}". ` +
|
|
202
|
+
`Add subscribers using matador.register(EventClass, [subscriber1, subscriber2]).`);
|
|
203
|
+
this.eventKey = eventKey;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Thrown when the schema configuration is invalid.
|
|
208
|
+
*/
|
|
209
|
+
export class InvalidSchemaError extends MatadorError {
|
|
210
|
+
cause;
|
|
211
|
+
description = 'The schema configuration is invalid. ' +
|
|
212
|
+
'ACTION: Review the schema registration for issues. Common problems: ' +
|
|
213
|
+
'(1) Duplicate subscriber names for the same event, ' +
|
|
214
|
+
'(2) Missing required fields on event class (key, description), ' +
|
|
215
|
+
'(3) Invalid alias configuration. ' +
|
|
216
|
+
'Check the cause property for specific details.';
|
|
217
|
+
constructor(message, cause) {
|
|
218
|
+
super(`Invalid schema: ${message}` + (cause ? `. Cause: ${cause}` : ''));
|
|
219
|
+
this.cause = cause;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Thrown when a subscriber is a stub but is being processed locally.
|
|
224
|
+
*/
|
|
225
|
+
export class SubscriberIsStubError extends MatadorError {
|
|
226
|
+
subscriberName;
|
|
227
|
+
description = 'A SubscriberStub was registered in a consuming schema. ' +
|
|
228
|
+
'ACTION: SubscriberStubs should only be used in producer schemas to declare ' +
|
|
229
|
+
'that a subscriber exists in another service. ' +
|
|
230
|
+
'In the consumer service, provide a full Subscriber with a callback function. ' +
|
|
231
|
+
'Remove the stub from the consumer schema and add the actual implementation.';
|
|
232
|
+
constructor(subscriberName) {
|
|
233
|
+
super(`Subscriber "${subscriberName}" is a stub and cannot be processed locally. ` +
|
|
234
|
+
`Replace with a full Subscriber implementation in the consumer schema.`);
|
|
235
|
+
this.subscriberName = subscriberName;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Thrown when a LocalTransport tries to process a stub subscriber.
|
|
240
|
+
*/
|
|
241
|
+
export class LocalTransportCannotProcessStubError extends MatadorError {
|
|
242
|
+
subscriberName;
|
|
243
|
+
description = 'The LocalTransport cannot process events for SubscriberStubs. ' +
|
|
244
|
+
'ACTION: SubscriberStubs represent remote implementations that only RabbitMQ can route. ' +
|
|
245
|
+
'If using LocalTransport for testing, provide mock implementations instead of stubs. ' +
|
|
246
|
+
'For production fallback scenarios, be aware that stub-targeted events will be dropped.';
|
|
247
|
+
constructor(subscriberName) {
|
|
248
|
+
super(`LocalTransport cannot process stub subscriber "${subscriberName}". ` +
|
|
249
|
+
`Stub subscribers require a distributed transport like RabbitMQ.`);
|
|
250
|
+
this.subscriberName = subscriberName;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
// ============================================================================
|
|
254
|
+
// Queue Errors
|
|
255
|
+
// ============================================================================
|
|
256
|
+
/**
|
|
257
|
+
* Thrown when a queue is not found or not created.
|
|
258
|
+
*/
|
|
259
|
+
export class QueueNotFoundError extends MatadorError {
|
|
260
|
+
queueName;
|
|
261
|
+
description = 'The specified queue does not exist or has not been created. ' +
|
|
262
|
+
'ACTION: Ensure the queue is defined in the topology configuration. ' +
|
|
263
|
+
'Call transport.applyTopology() or matador.start() to create queues. ' +
|
|
264
|
+
'Check that the queue name matches the topology definition.';
|
|
265
|
+
constructor(queueName) {
|
|
266
|
+
super(`Queue "${queueName}" not found. ` +
|
|
267
|
+
`Ensure it is defined in topology and applyTopology() was called.`);
|
|
268
|
+
this.queueName = queueName;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
// ============================================================================
|
|
272
|
+
// Event Validation Errors
|
|
273
|
+
// ============================================================================
|
|
274
|
+
/**
|
|
275
|
+
* Thrown when an event is invalid or malformed.
|
|
276
|
+
*/
|
|
277
|
+
export class InvalidEventError extends MatadorError {
|
|
278
|
+
cause;
|
|
279
|
+
description = 'The event is invalid or missing required fields. ' +
|
|
280
|
+
'ACTION: Ensure the event has all required properties. ' +
|
|
281
|
+
'Common issues: missing targetSubscriber during processing, ' +
|
|
282
|
+
'null/undefined data when the event type requires data, ' +
|
|
283
|
+
'malformed event structure from codec decode failure.';
|
|
284
|
+
constructor(message, cause) {
|
|
285
|
+
super(`Invalid event: ${message}` + (cause ? `. Cause: ${cause}` : ''));
|
|
286
|
+
this.cause = cause;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// ============================================================================
|
|
290
|
+
// Message Processing Errors
|
|
291
|
+
// ============================================================================
|
|
292
|
+
/**
|
|
293
|
+
* Thrown when a message has been redelivered too many times (poison message).
|
|
294
|
+
*/
|
|
295
|
+
export class MessageMaybePoisonedError extends MatadorError {
|
|
296
|
+
eventId;
|
|
297
|
+
deliveryCount;
|
|
298
|
+
maxDeliveries;
|
|
299
|
+
description = 'A message was redelivered multiple times without successful processing. ' +
|
|
300
|
+
'This usually indicates the message causes a crash or timeout during processing. ' +
|
|
301
|
+
'ACTION: (1) Check application logs for errors/crashes during message processing, ' +
|
|
302
|
+
'(2) Inspect the message in the dead-letter queue for malformed data, ' +
|
|
303
|
+
'(3) Review the subscriber code for bugs that cause crashes, ' +
|
|
304
|
+
'(4) Consider increasing processing timeout if the operation is legitimately slow. ' +
|
|
305
|
+
'This message will NOT be retried to prevent crash loops.';
|
|
306
|
+
constructor(eventId, deliveryCount, maxDeliveries) {
|
|
307
|
+
super(`Message "${eventId}" delivered ${deliveryCount} times (max: ${maxDeliveries}). ` +
|
|
308
|
+
`Possible poison message - will not be retried.`);
|
|
309
|
+
this.eventId = eventId;
|
|
310
|
+
this.deliveryCount = deliveryCount;
|
|
311
|
+
this.maxDeliveries = maxDeliveries;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Thrown when a non-idempotent message cannot be retried after redelivery.
|
|
316
|
+
*/
|
|
317
|
+
export class IdempotentMessageCannotRetryError extends MatadorError {
|
|
318
|
+
eventId;
|
|
319
|
+
subscriberName;
|
|
320
|
+
description = 'A non-idempotent subscriber received a redelivered message. ' +
|
|
321
|
+
'Retrying would risk duplicate side effects (e.g., double payments, duplicate emails). ' +
|
|
322
|
+
'ACTION: (1) Mark the subscriber as idempotent if it safely handles duplicates, ' +
|
|
323
|
+
'(2) Implement idempotency keys in the subscriber logic, ' +
|
|
324
|
+
'(3) Manually inspect and replay the message from the dead-letter queue after verification. ' +
|
|
325
|
+
'The message will be sent to the dead-letter queue for manual review.';
|
|
326
|
+
constructor(eventId, subscriberName) {
|
|
327
|
+
super(`Non-idempotent subscriber "${subscriberName}" cannot retry redelivered message "${eventId}". ` +
|
|
328
|
+
`Mark subscriber as idempotent='yes' or implement idempotency handling.`);
|
|
329
|
+
this.eventId = eventId;
|
|
330
|
+
this.subscriberName = subscriberName;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
// ============================================================================
|
|
334
|
+
// Timeout Errors
|
|
335
|
+
// ============================================================================
|
|
336
|
+
/**
|
|
337
|
+
* Thrown when an operation times out.
|
|
338
|
+
*/
|
|
339
|
+
export class TimeoutError extends MatadorError {
|
|
340
|
+
operation;
|
|
341
|
+
timeoutMs;
|
|
342
|
+
description = 'An operation timed out before completing. ' +
|
|
343
|
+
'ACTION: (1) Increase the timeout if the operation legitimately needs more time, ' +
|
|
344
|
+
'(2) Optimize the operation to complete faster, ' +
|
|
345
|
+
'(3) Check for deadlocks or blocking operations, ' +
|
|
346
|
+
'(4) Verify external service dependencies are responsive.';
|
|
347
|
+
constructor(operation, timeoutMs) {
|
|
348
|
+
super(`Operation "${operation}" timed out after ${timeoutMs}ms.`);
|
|
349
|
+
this.operation = operation;
|
|
350
|
+
this.timeoutMs = timeoutMs;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
// ============================================================================
|
|
354
|
+
// Type Guards
|
|
355
|
+
// ============================================================================
|
|
356
|
+
export function isMatadorError(error) {
|
|
357
|
+
return error instanceof MatadorError;
|
|
358
|
+
}
|
|
359
|
+
export function isNotStartedError(error) {
|
|
360
|
+
return error instanceof NotStartedError;
|
|
361
|
+
}
|
|
362
|
+
export function isTransportNotConnectedError(error) {
|
|
363
|
+
return error instanceof TransportNotConnectedError;
|
|
364
|
+
}
|
|
365
|
+
export function isEventNotRegisteredError(error) {
|
|
366
|
+
return error instanceof EventNotRegisteredError;
|
|
367
|
+
}
|
|
368
|
+
export function isSubscriberNotRegisteredError(error) {
|
|
369
|
+
return error instanceof SubscriberNotRegisteredError;
|
|
370
|
+
}
|
|
371
|
+
export function isMessageMaybePoisonedError(error) {
|
|
372
|
+
return error instanceof MessageMaybePoisonedError;
|
|
373
|
+
}
|
|
374
|
+
export function isIdempotentMessageCannotRetryError(error) {
|
|
375
|
+
return error instanceof IdempotentMessageCannotRetryError;
|
|
376
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for retry control errors.
|
|
3
|
+
* These errors control the retry behavior of message processing.
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class RetryControlError extends Error {
|
|
6
|
+
/**
|
|
7
|
+
* Error class name for monitoring tools.
|
|
8
|
+
*/
|
|
9
|
+
readonly name: string;
|
|
10
|
+
/**
|
|
11
|
+
* Human-readable description of the error and recommended actions.
|
|
12
|
+
*/
|
|
13
|
+
abstract readonly description: string;
|
|
14
|
+
constructor(message: string);
|
|
15
|
+
/**
|
|
16
|
+
* Returns a serializable representation for logging/monitoring.
|
|
17
|
+
*/
|
|
18
|
+
toJSON(): Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Forces retry regardless of subscriber idempotency setting.
|
|
22
|
+
* Use when you know the operation is safe to retry.
|
|
23
|
+
*
|
|
24
|
+
* ACTION: Check subscriber code to understand why retry was forced.
|
|
25
|
+
* This overrides default retry behavior based on idempotency settings.
|
|
26
|
+
*/
|
|
27
|
+
export declare class DoRetry extends RetryControlError {
|
|
28
|
+
readonly description: string;
|
|
29
|
+
constructor(message?: string);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Prevents retry regardless of subscriber idempotency setting.
|
|
33
|
+
* Use for permanent failures that should not be retried.
|
|
34
|
+
*
|
|
35
|
+
* ACTION: Check subscriber code to understand why retry was disabled.
|
|
36
|
+
* Typically used for permanent failures like invalid data or business rule violations.
|
|
37
|
+
*/
|
|
38
|
+
export declare class DontRetry extends RetryControlError {
|
|
39
|
+
readonly description: string;
|
|
40
|
+
constructor(message?: string);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Assertion error that should never be retried.
|
|
44
|
+
* Use for programming errors and invariant violations.
|
|
45
|
+
*
|
|
46
|
+
* ACTION: Review the assertion failure message to identify the bug
|
|
47
|
+
* in the event payload or subscriber logic.
|
|
48
|
+
*/
|
|
49
|
+
export declare class EventAssertionError extends Error {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly description: string;
|
|
52
|
+
constructor(message: string);
|
|
53
|
+
toJSON(): Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Checks if an error forces a retry.
|
|
57
|
+
*/
|
|
58
|
+
export declare function isDoRetry(error: unknown): error is DoRetry;
|
|
59
|
+
/**
|
|
60
|
+
* Checks if an error prevents retry.
|
|
61
|
+
*/
|
|
62
|
+
export declare function isDontRetry(error: unknown): error is DontRetry;
|
|
63
|
+
/**
|
|
64
|
+
* Checks if an error is an assertion error (never retry).
|
|
65
|
+
*/
|
|
66
|
+
export declare function isAssertionError(error: unknown): error is EventAssertionError;
|
|
67
|
+
//# sourceMappingURL=retry-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-errors.d.ts","sourceRoot":"","sources":["../../src/errors/retry-errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,8BAAsB,iBAAkB,SAAQ,KAAK;IACnD;;OAEG;IACH,SAAiB,IAAI,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAE1B,OAAO,EAAE,MAAM;IAY3B;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAQlC;AAED;;;;;;GAMG;AACH,qBAAa,OAAQ,SAAQ,iBAAiB;IAC5C,QAAQ,CAAC,WAAW,SAGyD;gBAEjE,OAAO,SAA2B;CAG/C;AAED;;;;;;GAMG;AACH,qBAAa,SAAU,SAAQ,iBAAiB;IAC9C,QAAQ,CAAC,WAAW,SAIqD;gBAE7D,OAAO,SAA8B;CAGlD;AAED;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,SAAiB,IAAI,EAAE,MAAM,CAAC;IAE9B,QAAQ,CAAC,WAAW,SAImB;gBAE3B,OAAO,EAAE,MAAM;IAW3B,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAQlC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAE7E"}
|