1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

fix #2665 - handle errors in multi/pipeline replies (#2666)

* fix #2665 - handle errors in multi/pipeline replies

* fix MultiErrorReply replies type

* run tests on all versions, remove console.log, fix bug

* add errors iterator helper

* test `.errors()` as well
This commit is contained in:
Leibale Eidelman
2023-12-18 15:15:21 -05:00
committed by GitHub
parent d6d2064c72
commit f4680f0849
3 changed files with 52 additions and 8 deletions

View File

@@ -1,3 +1,5 @@
import { RedisCommandRawReply } from './commands';
export class AbortError extends Error {
constructor() {
super('The command was aborted');
@@ -63,3 +65,20 @@ export class ErrorReply extends Error {
this.stack = undefined;
}
}
export class MultiErrorReply extends ErrorReply {
replies;
errorIndexes;
constructor(replies: Array<RedisCommandRawReply | ErrorReply>, errorIndexes: Array<number>) {
super(`${errorIndexes.length} commands failed, see .replies and .errorIndexes for more information`);
this.replies = replies;
this.errorIndexes = errorIndexes;
}
*errors() {
for (const index of this.errorIndexes) {
yield this.replies[index];
}
}
}