From b78d21a524f7a11ad29b4bd230f23825f80c3ed7 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 26 Jul 2020 15:02:55 +0800 Subject: Merge front end repo --- Timeline/ClientApp/src/app/utilities/rxjs.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Timeline/ClientApp/src/app/utilities/rxjs.ts (limited to 'Timeline/ClientApp/src/app/utilities/rxjs.ts') diff --git a/Timeline/ClientApp/src/app/utilities/rxjs.ts b/Timeline/ClientApp/src/app/utilities/rxjs.ts new file mode 100644 index 00000000..1be49164 --- /dev/null +++ b/Timeline/ClientApp/src/app/utilities/rxjs.ts @@ -0,0 +1,14 @@ +import { OperatorFunction } from 'rxjs'; +import { catchError } from 'rxjs/operators'; + +export function convertError( + oldErrorType: { new (...args: never[]): unknown }, + newErrorType: { new (): NewError } +): OperatorFunction { + return catchError((error) => { + if (error instanceof oldErrorType) { + throw new newErrorType(); + } + throw error; + }); +} -- cgit v1.2.3