-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.js
37 lines (30 loc) · 1.11 KB
/
errors.js
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
exports.RequestError = class RequestError extends Error {
constructor(messageOrInnerError, request, { response } = {}) {
const innerError = messageOrInnerError instanceof Error && messageOrInnerError;
const message = innerError ? messageOrInnerError.message : messageOrInnerError;
super(message);
Object.assign(this, {
request,
response,
...(innerError && innerError),
});
this.name = this.constructor.name;
Error.captureStackTrace(this, this.constructor);
}
};
exports.AckTimeoutError = class AckTimeoutError extends exports.RequestError {
constructor(request) {
const message = `Timed out waiting for consumer to acknowledge receipt of the request`;
super(message, request);
this.name = this.constructor.name;
Error.captureStackTrace(this, this.constructor);
}
};
exports.ResponseTimeoutError = class ResponseTimeoutError extends exports.RequestError {
constructor(request) {
const message = `Timed out waiting for response`;
super(message, request);
this.name = this.constructor.name;
Error.captureStackTrace(this, this.constructor);
}
};