Skip to content

The open alternative to Salesforce, designed for AI.

367 B
Raw Blame
import { isDefined } from '@/utils';

// https://github.com/microsoft/TypeScript/issues/34523
// oxlint-disable-next-line prefer-arrow/prefer-arrow-functions
export function assertIsDefinedOrThrow<T>(
  value: T | undefined | null,
  exceptionToThrow: Error = new Error('Value not defined'),
): asserts value is T {
  if (!isDefined(value)) throw exceptionToThrow;
}