From 4ee825baca21c21db844bdf718b6ec29dc6c3d42 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 27 Jul 2022 11:38:11 +0000 Subject: [PATCH] fix(@angular/cli): catch clause variable is not an Error instance Errors thrown in RxJs are not instanceof Error and therefore the check will always fail. Closes #23631 (cherry picked from commit 44f918612a43566c7e761cdcbc7fc87f8cc172f9) --- packages/angular/cli/src/utilities/error.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/angular/cli/src/utilities/error.ts b/packages/angular/cli/src/utilities/error.ts index 1e7644690f12..3b37aafc9dc3 100644 --- a/packages/angular/cli/src/utilities/error.ts +++ b/packages/angular/cli/src/utilities/error.ts @@ -9,5 +9,9 @@ import assert from 'assert'; export function assertIsError(value: unknown): asserts value is Error & { code?: string } { - assert(value instanceof Error, 'catch clause variable is not an Error instance'); + const isError = + value instanceof Error || + // The following is needing to identify errors coming from RxJs. + (typeof value === 'object' && value && 'name' in value && 'message' in value); + assert(isError, 'catch clause variable is not an Error instance'); }