Debian Codegraph @

node/rxjs/src/internal/util/UnsubscriptionError.ts

raw
1 import { createErrorClass } from './createErrorClass';
2
3 export interface UnsubscriptionError extends Error {
4 readonly errors: any[];
5 }
6
7 export interface UnsubscriptionErrorCtor {
8 /**
9 * @deprecated Internal implementation detail. Do not construct error instances.
10 * Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
11 */
12 new (errors: any[]): UnsubscriptionError;
13 }
14
15 /**
16 * An error thrown when one or more errors have occurred during the
17 * `unsubscribe` of a {@link Subscription}.
18 */
19 export const UnsubscriptionError: UnsubscriptionErrorCtor = createErrorClass(
20 (_super) =>
21 function UnsubscriptionErrorImpl(this: any, errors: (Error | string)[]) {
22 _super(this);
23 this.message = errors
24 ? `${errors.length} errors occurred during unsubscription:
25 ${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}`
26 : '';
27 this.name = 'UnsubscriptionError';
28 this.errors = errors;
29 }
30 );