belgattitude/httpx

View on GitHub
packages/exception/src/serializer/error/SerializerError.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { supportsErrorCause } from '../../support/supportsErrorCause';

export class SerializerError extends Error {
  constructor(
    message: string,
    params?: {
      cause?: Error | undefined;
    }
  ) {
    const { cause } = params ?? {};
    super(message);
    if (supportsErrorCause() && cause instanceof Error) {
      this.cause = cause;
    }
    Object.setPrototypeOf(this, SerializerError.prototype);
    this.name = 'SerializerError';
  }
}