import { ExceptionKind } from '../types'; import type { ExceptionsProps } from './platform-exception.absract'; import { PlatformException } from './platform-exception.absract'; /** * PipelineException is exception that occurs during request * or event handling. In both cases it raises inside Nest.js * pipeline and is meant to be caught by GlobalExceptionsFilter */ export abstract class PipelineException extends PlatformException { /** * All pipeline exceptions have "kind" field which allows to * map them to any specific transport exception. */ readonly kind: ExceptionKind; /** * @param kind kind of pipeline error * @param message error message * @param props additional properties */ constructor(kind: ExceptionKind, message: string, props?: ExceptionsProps) { const { code, ...other } = props || {}; super(code ?? `KIND:${ExceptionKind[kind]}`, message, other); this.kind = kind; } }