/
githubmirror
/
nest
Обзор
Документация
Войти
/
githubmirror
/
nest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages/core/helpers/external-proxy.ts
21 строка
714 B
Kamil Myśliwiec
build: use strict null checks part 2
26 ноя 2024, 15:36
Не верифицирован
26 ноя 2024, 15:36
2200897
Код
Авторство
О чём код?
import { ContextType } from '@nestjs/common/interfaces'; import { ExternalExceptionsHandler } from '../exceptions/external-exceptions-handler'; import { ExecutionContextHost } from '../helpers/execution-context-host'; export class ExternalErrorProxy { public createProxy<TContext extends string = ContextType>( targetCallback: (...args: any[]) => any, exceptionsHandler: ExternalExceptionsHandler, type?: TContext, ) { return async (...args: any[]) => { try { return await targetCallback(...args); } catch (e) { const host = new ExecutionContextHost(args); host.setType<TContext>(type!); return exceptionsHandler.next(e, host); } }; } }