blob: 0730b899286c8733f8a6e397f4b6c60309fe936c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import { OperatorFunction } from "rxjs";
import { catchError } from "rxjs/operators";
export function convertError<T, NewError>(
oldErrorType: { new (...args: never[]): unknown },
newErrorType: { new (): NewError }
): OperatorFunction<T, T> {
return catchError((error) => {
if (error instanceof oldErrorType) {
throw new newErrorType();
}
throw error;
});
}
|