Skip to content

Commit

Permalink
fix(@angular/cli): catch clause variable is not an Error instance
Browse files Browse the repository at this point in the history
Errors thrown in RxJs are not instanceof Error and therefore the check will always fail.

Closes #23631

(cherry picked from commit 44f9186)
  • Loading branch information
alan-agius4 committed Jul 28, 2022
1 parent 900f7ba commit 4ee825b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/angular/cli/src/utilities/error.ts
Expand Up @@ -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');
}

0 comments on commit 4ee825b

Please sign in to comment.